-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.prod.js
45 lines (43 loc) · 1.4 KB
/
webpack.prod.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
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const common = require('./webpack.common')
const CleanPlugin = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const UglifyPlugin = require('uglifyjs-webpack-plugin')
const WorkboxPlugin = require('workbox-webpack-plugin')
const DIST_DIR = 'dist'
module.exports = merge(common, {
output: {
filename: '[name].[chunkhash].js'
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new CleanPlugin([DIST_DIR]),
new UglifyPlugin({
sourceMap: true,
uglifyOptions: { mangle: { safari10: true } }
}),
new WorkboxPlugin({
globDirectory: DIST_DIR,
globPatterns: [
'*.{html,js,css}',
'**/webcomponents-loader.js',
'**/leaflet.css'
],
dontCacheBustUrlsMatching: /\.\w{20}\.js/,
swSrc: './service-worker.js',
swDest: path.join(DIST_DIR, 'service-worker.js')
}),
new CopyPlugin([
{ from: 'manifest.json' },
{ from: 'images', to: 'images' },
{ from: 'node_modules/workbox-sw', to: 'node_modules/workbox-sw' },
{ from: 'bower_components/webcomponentsjs', to: 'bower_components/webcomponentsjs' },
{ from: 'bower_components/leaflet', to: 'bower_components/leaflet' }
])
]
})