-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
41 lines (39 loc) · 1.14 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env) => ({
entry: path.resolve(__dirname, './src/App.tsx'),
output: {
path: path.join(__dirname, 'dist')
},
module: {
rules: [
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] },
{ test: /\.tsx?$/, use: 'ts-loader' }
]
},
plugins: [
new HTMLWebpackPlugin({
template: path.join(__dirname, 'src', 'index.html'),
}),
new MiniCssExtractPlugin(),
new WorkboxWebpackPlugin.InjectManifest({
swSrc: path.join(__dirname, 'src', 'sw.ts'),
swDest: 'sw.js',
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024
}),
new CopyWebpackPlugin({
patterns: [
{from: 'static'}
]
})
],
resolve: {
extensions: ['.js', '.json', '.jsx', '.ts', '.tsx']
},
devtool: env.production ? undefined : 'source-map',
mode: env.production ? 'production' : 'development'
});