-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathwebpack.config.js
74 lines (71 loc) · 2.12 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
62
63
64
65
66
67
68
69
70
71
72
73
74
const path = require('path')
const webpack = require("webpack")
const CleanPlugin = require("clean-webpack-plugin")
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require("copy-webpack-plugin")
//设置输入和输出根目录
const ROOT_PATH = path.resolve(__dirname)
const APP_PATH = path.resolve(ROOT_PATH, 'src');
const BUILD_PATH = path.resolve(__dirname, 'dist')
module.exports = {
entry: './src/index.js',
output: {
path: BUILD_PATH,
library: 'datePicker',
libraryTarget: 'umd',
filename: "date-picker.min.js"
},
devtool: false,
devServer: {
contentBase: ROOT_PATH,
historyApiFallback: true,
hot: true,
open: true,
inline: true,
port: 8888
},
module: {
rules: [{
test: /\.js$/,
loader: "eslint-loader",
exclude: /node_modules/,
enforce: 'pre'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['es2015'],
plugins: [
["transform-runtime"]
]
}
}]
},
plugins: [
new CleanPlugin([BUILD_PATH]),
new CopyWebpackPlugin([{
from: path.resolve(APP_PATH, './datePicker.css'),
to: path.resolve(BUILD_PATH)
}]),
new webpack.optimize.ModuleConcatenationPlugin(),
//热插拔
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
filename: "index.html", //生成的html存放路径,相对于 path
template: "./src/index.html",
inject: true, //允许插件修改哪些内容,包括head与body
hash: true, //为静态资源生成hash值
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false
},
comments: false,
beautify: false,
sourceMap: false
})
]
}