forked from gorisanson/pikachu-volleyball
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
57 lines (56 loc) · 1.66 KB
/
Copy pathwebpack.common.js
File metadata and controls
57 lines (56 loc) · 1.66 KB
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
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
module.exports = {
entry: { main: './src/resources/js/main.js', ko: './src/ko/ko.js' },
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
runtimeChunk: { name: 'runtime' }, // this is for code-sharing between "main.js and "ko.js"
splitChunks: {
chunks: 'all',
},
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin([
{
context: 'src/',
from: 'resources/assets/**/*.+(json|png|mp3|wav)',
},
{ from: 'src/en/manifest.json', to: 'en/manifest.json' },
{ from: 'src/ko/manifest.json', to: 'ko/manifest.json' },
{ from: 'src/resources/style.css', to: 'resources/style.css' },
{ from: 'src/index.html', to: 'index.html' },
]),
new HtmlWebpackPlugin({
template: 'src/en/index.html',
filename: 'en/index.html',
chunks: ['runtime', 'main'],
chunksSortMode: 'manual',
minify: {
collapseWhitespace: true,
removeComments: true,
},
}),
new HtmlWebpackPlugin({
template: 'src/ko/index.html',
filename: 'ko/index.html',
chunks: ['runtime', 'ko', 'main'],
chunksSortMode: 'manual',
minify: {
collapseWhitespace: true,
removeComments: true,
},
}),
new WorkboxPlugin.GenerateSW({
swDest: 'sw.js',
cleanupOutdatedCaches: true,
skipWaiting: false,
}),
],
};