-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.build.js
More file actions
95 lines (91 loc) · 2.03 KB
/
webpack.build.js
File metadata and controls
95 lines (91 loc) · 2.03 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const webpack = require('webpack');
const packageJSON = require('./package.json');
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
let libraryName = 'maby-editor';
let plugins = [];
console.log('✅ 当前是 发布 模式');
plugins = [
new HtmlWebpackPlugin({
title: 'maby-editor测试',
template: __dirname + '/public/index.html'
}),
new UglifyJsPlugin({
minimize: true,
compress: {
warnings: false,
drop_debugger: true,
drop_console: true
}
}),
new CleanWebpackPlugin(['preview'])
];
console.log(' ./preview 目录已删除,正在打包当前版本 %s', packageJSON.version);
let config = {
entry: {
main: __dirname + '/example/index.js',
},
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'preview'),
filename: libraryName + '.min.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
'./'
],
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', "stage-0"]
}
}, {
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
}, {
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
]
}, {
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
}, {
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader'
]
}, {
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 51200
}
}
]
}
]
},
plugins: plugins
};
module.exports = config;