-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
72 lines (71 loc) · 2.13 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
const glob = require('glob');
const { resolve } = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TsconfigPathsWebpackPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = (_, argv) => ({
target: 'web',
entry: resolve(__dirname, './src/index.tsx'),
output: {
filename: '[name].[chunkhash].js',
path: resolve(__dirname, './dist'),
publicPath: '/'
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader'
},
{
test: /\.less$/,
exclude: [/\.module.less$/],
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true
}
}
}
]
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: resolve(__dirname, './public'), to: resolve(__dirname, './dist') }
]
}),
new HtmlWebpackPlugin({
template: resolve(__dirname, './src/index.ejs')
}),
new MiniCssExtractPlugin({
filename: '[name].[chunkhash].css'
})
],
resolve: {
extensions: ['.css', '.less', '.js', '.json', '.ts', '.tsx'],
modules: [resolve(__dirname, './src'), resolve(__dirname, './node_modules')],
plugins: [new TsconfigPathsWebpackPlugin()]
},
optimization: {
minimize: true,
splitChunks: {
chunks: 'all'
}
}
});