forked from globalizejs/globalize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-config.js
55 lines (53 loc) · 1.58 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
var webpack = require( "webpack" );
var CommonsChunkPlugin = require( "webpack/lib/optimize/CommonsChunkPlugin" );
var HtmlWebpackPlugin = require( "html-webpack-plugin" );
var GlobalizePlugin = require( "globalize-webpack-plugin" );
var nopt = require( "nopt" );
var options = nopt({
production: Boolean
});
module.exports = {
entry: options.production ? {
main: "./app/index.js",
vendor: [
"globalize",
"globalize/dist/globalize-runtime/number",
"globalize/dist/globalize-runtime/currency",
"globalize/dist/globalize-runtime/date",
"globalize/dist/globalize-runtime/message",
"globalize/dist/globalize-runtime/plural",
"globalize/dist/globalize-runtime/relative-time",
"globalize/dist/globalize-runtime/unit"
]
} : "./app/index.js",
debug: !options.production,
output: {
path: options.production ? "./dist" : "./tmp",
publicPath: options.production ? "" : "http://localhost:8080/",
filename: options.production ? "app.[hash].js" : "app.js"
},
resolve: {
extensions: [ "", ".js" ]
},
plugins: [
new HtmlWebpackPlugin({
production: options.production,
template: "./index-template.html"
}),
new GlobalizePlugin({
production: options.production,
developmentLocale: "en",
supportedLocales: [ "ar", "de", "en", "es", "pt", "ru", "zh" ],
messages: "messages/[locale].json",
output: "i18n/[locale].[hash].js"
})
].concat( options.production ? [
new webpack.optimize.DedupePlugin(),
new CommonsChunkPlugin( "vendor", "vendor.[hash].js" ),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
] : [] )
};