Default Webpack Config

Home   »   Default Webpack Config

var wp = require('webpack');
var path = require('path');
var fs = require('fs')



// use for hashing transpiled js file to get around browser caching

// class MetaInfoPlugin {
//   constructor(options) {
//     this.options = { filename: '../client-meta.json', ...options };
//   }

//   apply(compiler) {
//     compiler.hooks.done.tap(this.constructor.name, stats => {
//       const metaInfo = {
//         // add any other information if necessary
//         hash: stats.hash
//       };
//       const json = JSON.stringify(metaInfo);
//       return new Promise((resolve, reject) => {
//         fs.writeFile(this.options.filename, json, 'utf8', error => {
//           if (error) {
//             reject(error);
//             return;
//           }
//           resolve();
//         });
//       });
//     });
//   }
// }





module.exports = {
	entry : "./src/app.js",
	output : {
		
		path : path.resolve("../wwwroot/compiled"),
		filename : "app.js"
	},

	optimization : {
        minimize : true
    },

    resolve : {
		alias : {
            "~" : path.resolve(__dirname,"src")
        },
        extensions : [ ".js" ]
    },
	plugins: [
        // make sure to include the plugin!
        
        //new MetaInfoPlugin()
    ],
    mode:"development",

    module : {
    	rules : [
            {
                test: /\.js$/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env','@babel/preset-react'],
                        plugins : ["transform-object-rest-spread"]
                    }
                },
                exclude: /node_modules/
            },
        ]
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *