-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
136 lines (131 loc) · 4.28 KB
/
webpack.dev.config.js
File metadata and controls
136 lines (131 loc) · 4.28 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var CleanWebpackPlugin = require('clean-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ReplacePlugin = require('replace-webpack-plugin');
// var ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require("path");
var moment = require('moment');
module.exports = {
entry: {
index: './js/c.js',
index1: './js/c.js'
},
output: {
path: path.join( __dirname,"/dist/js/"),
filename: "[name].[hash:8].bundle.js",
publicPath: "./js"
},
// resolve: { //可以把公共库转变为局部变量
// //root: path.join(__dirname,'/src/components/'),
// //root: "./src",
// modulesDirectories: ['node_modules','src'],
// extensions: ["", ".js", ".css", ".json"]
// },
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel",
query:{
presets: ['es2015']
// ,
// plugins: [["antd", {"style":false}]]
}
// loader:"babel-loader" ---用这个就不需要.babelrc
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
}
// {
// test: /\.css$/,
// loader: ExtractTextPlugin.extract({
// fallbackLoader: "style-loader",
// loader: "css-loader"
// })
// }
,
{
test: /\.less$/,
loader: "style!css!less"
},
{ test:/\.(png|woff|svg|ttf|eot|jpg)$/,loader:'url-loader?limit=10000'}//限制大小小于10k的
]
},
plugins: [
// new CleanWebpackPlugin(['dist'], {
// verbose: true //清除构建目录
// }),
new webpack.DefinePlugin({'process.env.NODE_ENV': JSON.stringify('dev')}),
new webpack.optimize.DedupePlugin(),
// new webpack.optimize.UglifyJsPlugin({
// compress:{
// warnings: false,
// dead_code: true,
// drop_debugger: true,
// unused:true,
// drop_console: true,
// collapse_vars: true
// },
// /* 清除所有注释 */
// comments: function () {
// return "";
// }
// }),
new webpack.BannerPlugin("gamdale erp pkg time:" + moment().format()),
// new webpack.optimize.CommonsChunkPlugin({
// name:["libs"],
// // filename:'libs.min.js',
// minChunks:Infinity,
// async:true
// }),
// new webpack.optimize.AggressiveMergingPlugin(),
new HtmlWebpackPlugin({
template: "dist/temphtml/index.html",
filename: "../index.html",
inject: "body",
chunks: ["index"]
}),
new HtmlWebpackPlugin({
template: "dist/temphtml/index1.html",
filename: "../index1.html",
inject: "body",
chunks: ["index1"]
})
// new HtmlWebpackPlugin({
// template: "html/index.html",
// filename: "../temphtml/index.html",
// inject: "body",
// chunks: ["index"]
// }),
// new HtmlWebpackPlugin({
// template: "html/index1.html",
// filename: "../temphtml/index1.html",
// inject: "body",
// chunks: ["index1"]
// })
// "htmlWebpackPlugin": {
// "files": {
// "css": [ "main.css" ],
// "js": [ "assets/head_bundle.js", "assets/main_bundle.js"],
// "chunks": {
// "head": {
// "entry": "assets/head_bundle.js",
// "css": [ "main.css" ]
// },
// "main": {
// "entry": "assets/main_bundle.js",
// "css": []
// },
// }
// }
// }
// new ExtractTextPlugin("styles.css"),
// new CopyWebpackPlugin([
// {from:"./images",to:"../images/"},
// {from:"./css",to:"../css/"}
// ])
]
};