diff options
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..99bbe49 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,36 @@ +const path = require('path'); +const webpack = require('webpack'); + +module.exports = (env, argv) => { + const commonConf = { + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: 'babel-loader', + }, { + test: /\.css$/, + use: ['style-loader', 'css-loader'], + }, + ], + }, + }; + + const devConf = { + devServer: { + port: 3000, + contentBase: path.resolve(__dirname, './src'), + hot: true, + stats: 'minimal', + }, + devtool: 'source-map', + plugins: [new webpack.HotModuleReplacementPlugin()], + }; + + if (argv.mode === 'development') { + return { ...commonConf, ...devConf }; + } + + return commonConf; +}; |