-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebpack.npm.js
72 lines (68 loc) · 1.79 KB
/
webpack.npm.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
/**
* Created by liuzhengdong on 2017/7/6.
*/
const path = require('path')
const webpack = require('webpack')
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const getVueLoaderConfig = require('./config/vue-loader.conf')
// 版本号
function resolve(dir) {
return path.resolve(process.cwd(), dir)
}
const vueLoaderConfig = getVueLoaderConfig('prod')
const config = {
// 入口模块配置
entry: {
app: path.join(__dirname, 'lib/ml/index.js'), // 入口
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
// 输出模块配置
output: {
// 输出到这个目录下
path: resolve('release/'),
// 生成的文件名, [name] 即为entry配置中的key
filename: 'ml-ui.js',
libraryTarget: 'umd', // 输出格式
umdNamedDefine: true // 是否将模块名称作为 AMD 输出的命名空间
},
// 寻找模块时的一些缺省设置
resolve: {
// 补充扩展名
extensions: ['.js', '.vue', '.json'],
},
module: {
rules: [
{
test: /\.vue$/,
use: [vueLoaderConfig, 'eslint-loader'],
},
{
test: /\.js$/,
use: ['babel-loader', 'eslint-loader'],
exclude: /node_modules/,
},
],
},
plugins: [
// 由于mac不区分大小写,linux区分大小写,可能导致mac上正常,在部署时出错,所以强制区分大小写
new CaseSensitivePathsPlugin(),
// // js压缩
new webpack.optimize.UglifyJsPlugin({
comments: false, // 去掉注释
compress: {
warnings: false, // 不显示警告
drop_console: false,
},
}),
// Scope Hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
],
}
module.exports = config