-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
76 lines (74 loc) · 1.84 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
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
/*global require, module, __dirname */
require('webpack');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
module.exports = {
entry: './web-src/index.tsx',
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.css$/,
use: [{ loader: MiniCssExtractPlugin.loader }, { loader: 'css-loader' }]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader']
}
]
},
resolve: {
extensions: ['*', '.ts', '.tsx', '.js', '.jsx']
},
output: {
path: __dirname + '/web',
publicPath: './',
filename: 'bundle.js'
},
optimization: {
minimize: true,
splitChunks: {
chunks: 'all',
cacheGroups: {
react: {
priority: 100,
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'react',
filename: '[name].bundle.js',
enforce: true
},
common: {
priority: 1,
test: /[\\/]node_modules[\\/]/,
name: 'common',
filename: '[name].bundle.js',
enforce: true
}
}
}
},
devtool: 'source-map',
plugins: [
new MiniCssExtractPlugin({
filename: 'main.css'
}),
new HtmlWebPackPlugin({
title: 'Openbravo - Web Hardware',
template: './web-src/index.html',
favicon: './web-src/favicon.ico',
filename: 'index.html'
}),
new WorkboxPlugin.GenerateSW({
// Progressive web application. PWA.
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true
})
]
};