-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.development.js
64 lines (62 loc) · 1.58 KB
/
webpack.config.development.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
const path = require("path")
const {VueLoaderPlugin} = require('vue-loader')
const htmlPlugin = require("html-webpack-plugin");
module.exports = {
mode: "development",
entry: {
exampleTitle: "./example/BaseCardComponent/index.js"
},
// target: 'node', // 这是最关键的
target: 'web', // <=== 默认为 'web',可省略
output: {
filename: "./[name].[chunkhash:5].js",
path: path.resolve(__dirname, "dist"),
library: {
type: "umd"
},
// libraryExport: 'default',
umdNamedDefine: true,
// 为了构建web应用,打包后如果想在nodejs环境使用的,那么打包后的资源里面又self变量,
// 该变量是浏览器端独有,所有为了能够让包既能在web端使用,又能在nodejs端使用,因此添加慈航代码,兼容标识全局
globalObject: 'typeof self !== \'undefined\' ? self : this'
},
resolve: {
// 兼容处理后缀名,比如导入导出的时候,不需要写后缀名,让webpack进行自我推断
extensions: [".js", ".vue"]
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: file => (
/node_modules/.test(file) &&
!/\.vue\.js/.test(file)
),
options: {
"presets": [
["@babel/preset-env"]
],
},
},
]
},
plugins: [
// 请确保引入这个插件!
new VueLoaderPlugin(),
new htmlPlugin({
title: "组件测试的案例",
filename: "BaseCardComponent.html",
template: "./example/BaseCardComponent/index.html"
})
],
devServer: {
compress: true,
port: 9000,
hot: true
}
}