-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
56 lines (53 loc) · 1.38 KB
/
webpack.dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const workboxPlugin = require('workbox-webpack-plugin');
const CleanPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const DIST_DIR = `${path.resolve()}/dist`;
module.exports = {
entry: {
app: './src/client/index.js',
vendor: ['react', 'react-dom']
},
devtool: 'inline-source-map',
output: {
filename: '[name].[chunkhash].js',
path: DIST_DIR
},
plugins: [
new CleanPlugin([DIST_DIR]),
new CopyWebpackPlugin([
{ from: 'src/client/manifest.json', to: `${DIST_DIR}` },
]),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
new HtmlWebpackPlugin({
template: './src/client/index.html',
filename: 'index.html'
}),
new workboxPlugin.GenerateSW({
swDest: `${DIST_DIR}/sw.js`,
clientsClaim: true,
skipWaiting: true,
}),
],
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
}
],
}
};