/
webpack.config.js
48 lines (45 loc) · 1.48 KB
/
webpack.config.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
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
module.exports = (environment, argv) => {
const isProduction = argv.mode === 'production';
const mode = isProduction ? 'production' : 'development';
console.info('Mode:', '\u001B[1m' + mode + '\u001B[0m');
return {
mode,
devtool: isProduction ? 'none' : 'source-map',
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
new WorkboxPlugin.GenerateSW(),
new CopyWebpackPlugin([
{
from: './src/assets/root',
to: './',
},
]),
new HtmlWebPackPlugin({
minify: isProduction,
hash: isProduction,
template: './src/index.html',
filename: './index.html',
title: process.env.npm_package_title || 'App',
meta: {
viewport: 'width=device-width, initial-scale=1.0',
'theme-color': '#333',
},
}),
],
};
};