-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
171 lines (158 loc) · 3.98 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
var webpack = require("webpack"),
HtmlWebpackPlugin = require("html-webpack-plugin"),
autoprefixer = require("autoprefixer"),
ngAnnotatePlugin = require("ng-annotate-webpack-plugin"),
CopyWebpackPlugin = require("copy-webpack-plugin"),
_ = require("lodash"),
path = require("path"),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
env = _.trim(process.env.NODE_ENV);
console.log(
"=============================" + env + "============================="
);
console.log(
"=============================" + __dirname + "============================="
);
var webpackConfig = {
devtool: "cheap-module-source-map", //generate source map for developing
entry: {
app: __dirname + "/app/core/bootstrap.js", //the main file for start app
vendor: [
// 'angular',
// 'angular-route',
// 'angular-ui-bootstrap',
// 'lodash',
// 'bootstrap',
// 'bootstrap-loader',
// 'jquery'
]
},
output: {
// publicPath: __dirname + "/public",
path: __dirname + "/dist", //the path saving packed file
// filename: "bundle[hash].js" //the out put file name
filename: "bundle.js"
},
devServer: {
contentBase: "./", //webpack server read file path
colors: true, //terminal shows log with color
historyApiFallback: true, //
progress: true,
compress: true,
disableHostCheck: true,
port: 9000,
proxy: {
"/game-be": {
target: "http://127.0.0.1:8888/",
secure: false,
pathRewrite: {"^/game-be" : ""}
}
}
},
resolve: {
extensions: ["", ".webpack.js", ".web.js", ".ts", ".js"],
alias: {
moment: path.join(
__dirname,
"/node_modules/moment/min/moment-with-locales.js"
),
"font-awesome": path.join(
__dirname,
"/node_modules/font-awesome/scss/font-awesome.scss"
)
}
},
module: {
//
noParse: [/moment-with-locales/],
loaders: [
{
test: /\.json$/,
loader: "json"
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel",
query: {
presets: ["es2015"]
}
},
{
test: /\.scss$/,
// loader: 'style!css!postcss!sass',
loader: ExtractTextPlugin.extract([
"css-loader",
"postcss-loader",
"sass-loader"
])
// exclude: /node_modules/,
},
{
test: /\.html$/,
loader: "html-loader",
exclude: /node_modules/
},
{
test: /dist\/js\/umd\//,
loader: "imports?jQuery=jquery"
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/,
loader: "file"
}
// {
// test: /\.tsx?$/,
// loader: 'ts-loader'
// }
]
},
postcss: function() {
return [autoprefixer];
},
plugins: [
new HtmlWebpackPlugin({
filename: "./index.html",
template: __dirname + "/app/index.html" //packed js append to index.html,set index.html path
}),
new webpack.DefinePlugin({
"process.env": "'" + env + "'"
}),
new webpack.optimize.CommonsChunkPlugin(
/* chunkName= */ "vendor",
/* filename= */ "vendor.bundle.js"
),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery",
jquery: "jquery"
}),
new ngAnnotatePlugin({ add: true }),
new webpack.DllReferencePlugin({
context: __dirname + "",
manifest: require("./app/assets/dll/vendor-manifest.json")
}),
new CopyWebpackPlugin([
{
from: "./app/assets",
to: "assets"
}
]),
new ExtractTextPlugin("style.css", {
allChunks: true
})
]
};
if (env == "prod") {
console.log(
"=============================start uglify============================="
);
webpackConfig.plugins = webpackConfig.plugins.concat([
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]);
}
module.exports = webpackConfig;