-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
61 lines (60 loc) · 1.5 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: "./src/test.tsx", // 本地测试
// entry: "./src/index.tsx", // 打包
output: {
filename: "react-cascader-transfer.js",
path: path.resolve(__dirname),
libraryTarget: 'umd',
},
// Enable sourcemaps for debugging webpack's output.
// devtool: "source-map",
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
{
test: /\.(js|jsx|tsx|ts)?$/,
exclude: /node_modules/,
use: ["babel-loader", "ts-loader"]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
]
},
]
},
plugins: [
new HtmlWebpackPlugin({ // 本地测试需要放开
template: path.resolve(__dirname, 'index.html')
})
],
// externals: { // 打包到生产并发布到npm上需要开启,因为用到了react hooks,不然会因为有两个react副本而导致hooks报错,本地测试需要注掉
// react: {
// root: 'React',
// commonjs2: 'react',
// commonjs: 'react',
// amd: 'react'
// },
// 'react-dom': {
// root: 'ReactDOM',
// commonjs2: 'react-dom',
// commonjs: 'react-dom',
// amd: 'react-dom'
// }
// },
};