forked from yuameshi/PhiCommunity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
37 lines (32 loc) · 881 Bytes
/
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
const { merge } = require('webpack-merge');
const common = require('./webpack.common');
const { InjectManifest } = require('workbox-webpack-plugin');
const path = require('path');
module.exports = (env) => {
console.log(env);
const chartsSource = env['charts-source'] || 'default';
if (chartsSource) console.log('Deploy with charts source: ' + chartsSource);
const loaders = [];
if (chartsSource !== 'default')
loaders.push({
test: /\.js$/,
loader: 'string-replace-loader',
options: {
search: /https:\/\/charts\.phicommunity\.com\.cn/gi,
replace: chartsSource,
},
});
return merge(common, {
mode: 'production',
plugins: [
new InjectManifest({
swSrc: path.resolve(__dirname, '../src', 'sw.js'),
swDest: 'service-worker.js',
exclude: [/service-worker\.js/, /sw\.js/],
}),
],
module: {
rules: [...loaders],
},
});
};