Created
February 12, 2019 21:10
-
-
Save mikecole/21a7df01287a960bebde9b6f2f7f5be0 to your computer and use it in GitHub Desktop.
webpack setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
module.exports = { | |
entry: { | |
login: './Scripts/apps/login.jsx', | |
'mass-update': './Scripts/apps/mass-update/app.jsx', | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.(js|jsx)$/, | |
exclude: /node_modules/, | |
use: ['babel-loader'], | |
}, | |
{ | |
test:/\.(s*)css$/, | |
use:['style-loader','css-loader', 'sass-loader'], | |
}, | |
] | |
}, | |
resolve: { | |
extensions: ['*', '.js', '.jsx'], | |
}, | |
output: { | |
path: path.join(__dirname, 'scripts', 'dist'), | |
publicPath: '/', | |
filename: '[name].bundle.js', | |
}, | |
plugins: [ | |
new CleanWebpackPlugin([path.join(__dirname, 'scripts', 'dist')]), | |
] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const merge = require('webpack-merge'); | |
const common = require('./webpack.common.js'); | |
module.exports = merge(common, | |
{ | |
mode: 'development', | |
devtool: 'inline-source-map', | |
devServer: { | |
contentBase: './Scripts/dist' | |
}, | |
watch: true, | |
watchOptions: { | |
aggregateTimeout: 300, | |
poll: 1000, | |
ignored: './node_modules/' | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack'); | |
const merge = require('webpack-merge'); | |
const common = require('./webpack.common.js'); | |
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | |
module.exports = merge(common, { | |
mode: 'production', | |
devtool: 'source-map', | |
plugins: [ | |
new UglifyJSPlugin({ | |
sourceMap: true | |
}), | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('production') | |
}) | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment