-
Notifications
You must be signed in to change notification settings - Fork 130
/
webpack.config.build.lib.js
executable file
·39 lines (37 loc) · 1.32 KB
/
webpack.config.build.lib.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const dirApp = path.join(__dirname, 'app');
/**
* Webpack Configuration
*/
module.exports = {
entry: path.join(dirApp, 'lib/address-parse.js'),
output: {
filename: 'zh-address-parse.min.js', //打包之后生成的文件名,可以随意写。
library: 'ZhAddressParse', // 指定类库名,主要用于直接引用的方式(比如使用script 标签)
libraryExport: "default", // 对外暴露default属性,就可以直接调用default里的属性
globalObject: 'this', // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
libraryTarget: 'umd' // 定义打包方式Universal Module Definition,同时支持在CommonJS、AMD和全局变量使用
},
mode: "production",
module: {
rules: [
// BABEL
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules)/,
options: {
compact: true
}
},
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'index.html'),
title: 'zh-address-parse'
})
],
};