forked from hatnote/monumental-wlm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·113 lines (108 loc) · 2.8 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
var path = require("path");
var webpack = require("webpack");
var CopyWebpackPlugin = require("copy-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var ngAnnotatePlugin = require("ng-annotate-webpack-plugin");
var package = require("./package.json");
var config = {
context: path.join(__dirname, "src"),
entry: ["babel-polyfill", "./index.js"],
output: {
path: path.join(__dirname, "monumental", "static", "assets"),
publicPath: "assets/",
filename: "bundle.js?v=" + package.version
},
plugins: [
new HtmlWebpackPlugin({
template: "index_local.ejs",
filename: path.join("..", "index.html")
}),
new CopyWebpackPlugin([
{ from: "manifest_local.json", to: path.join("..", "manifest.json") },
{ from: "app-icons", to: "app-icons" }
]),
function () {
this.plugin("watch-run", function (watching, callback) {
console.log(
"\n\n---- " +
new Date()
.toISOString()
.replace("T", " ")
.replace(/\.[0-9]+Z/, "") +
" ----"
);
callback();
});
}
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel",
query: {
plugins: ["transform-runtime"],
presets: ["es2015", "stage-2"]
}
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "ng-annotate"
},
{
test: /\.html?$/,
loader: "raw"
},
{
test: /\.css$/,
loader: "style!css"
},
{
test: /\.scss$/,
loader: "style!css!sass"
},
{
test: /\.(woff|woff2|ttf|eot)$/,
loader: "file?name=fonts/[name].[ext]"
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: "file?name=images/[name].[ext]"
},
{
test: /\.json$/,
loader: "json"
}
]
}
};
var ENV = process.env.NODE_ENV;
if (ENV === "prod" || ENV === "dev") {
config.output = {
path: path.join(__dirname, "monumental", "static", "assets"),
publicPath: "assets/",
filename: "bundle.min.js?v=" + package.version
};
config.plugins = [
new HtmlWebpackPlugin({
template: ENV === "dev" ? "index_dev.ejs" : "index_prod.ejs",
filename: path.join("..", "index.html")
}),
new CopyWebpackPlugin([
{ from: "manifest_dev.json", to: path.join("..", "manifest.json") },
{ from: "app-icons", to: "app-icons" }
]),
new ngAnnotatePlugin({
add: true
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
mangle: true
})
];
}
module.exports = config;