-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
98 lines (96 loc) · 2.21 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const workbox = require('workbox-webpack-plugin');
const config = {
entry: ['core-js/fn/promise', 'core-js/fn/array/find', 'whatwg-fetch', './src/index.js'],
devtool: 'inline-source-map',
mode: 'development',
output: {
path: __dirname + '/dist',
filename: 'scripts/[name].js',
},
devServer: {
publicPath: "/",
contentBase: './dist',
compress: true,
port: 9000,
historyApiFallback: true,
},
optimization: {
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `npm.${packageName.replace('@', '')}`;
},
},
},
}
},
module: {
rules: [
{
test: /\.js$/,
include: /(src)/,
use: [
{
loader: 'babel-loader',
},
],
},
{
test: /\.css$/,
include: /(src)/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]',
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('precss'),
];
}
}
}
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader?name=/images/[name].[ext]'
]
}
],
},
plugins: [
new CopyWebpackPlugin([
{
from: 'public'
}
]),
new HtmlWebpackPlugin({
template: './public/index.html',
}),
new workbox.GenerateSW({
swDest: 'service-worker.js',
clientsClaim: true,
skipWaiting: true,
runtimeCaching: []
})
],
};
module.exports = config;