-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
57 lines (55 loc) · 1.27 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const _PROD_ = process.env.NODE_ENV === 'production'
module.exports = {
mode: _PROD_ ? 'production' : 'development',
// devtool: '',
entry: './src/index.tsx',
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js',
libraryTarget: 'umd',
},
module: {
rules: [
{
test: /\.(t|j)sx?/,
loader: 'babel-loader',
},
{
test: /\.less$/,
use: [
_PROD_ ? MiniCssExtractPlugin.loader : 'style-loader',
'css-loader',
'less-loader'
],
},
],
},
resolve: {
// 用于查找模块的目录
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
externals: {
'react': 'react',
'react-dom': 'react-dom'
},
devServer: {
port: 3005,
},
optimization: {
minimizer: [
new CssMinimizerPlugin(),
],
},
plugins: [
_PROD_ ? new MiniCssExtractPlugin({
filename: "./index.css",
}) : new HtmlWebpackPlugin({
template: path.join(__dirname, './example/index.html'),
filename: './index.html',
})
]
}