-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config-prod.js
135 lines (113 loc) · 4.41 KB
/
webpack.config-prod.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
let Webpack = require("webpack");
//let ExtractTextPlugin = require("extract-text-webpack-plugin");
export default {
// Compilation target http://webpack.github.io/docs/configuration.html#target
target: "web",
// Debug mode http://webpack.github.io/docs/configuration.html#debug
debug: false,
// Enhance debugging http://webpack.github.io/docs/configuration.html#devtool
devtool: undefined,
// Capture timing information http://webpack.github.io/docs/configuration.html#profile
profile: false,
// Entry files http://webpack.github.io/docs/configuration.html#entry
entry: {
main: "./frontend/app-react", // TODO other pages ?!
},
// Output files http://webpack.github.io/docs/configuration.html#output
output: {
path: __dirname + "/public",
publicPath: "/public/",
filename: "[name].js?[chunkhash]",
chunkFilename: "[name].js?[chunkhash]", // TODO need?
sourceMapFilename: "debugging/[file].map",
libraryTarget: undefined,
pathinfo: false,
},
// Module http://webpack.github.io/docs/configuration.html#module
module: {
loaders: [ // http://webpack.github.io/docs/loaders.html
// JS
{test: /\.(js(\?.*)?)$/, loaders: ["babel"], exclude: /node_modules/ }, // ?stage=2 ????
// JSON
{test: /\.(json(\?.*)?)$/, loaders: ["json"]},
{test: /\.(json5(\?.*)?)$/, loaders: ["json5"]},
// RAW
{test: /\.(txt(\?.*)?)$/, loaders: ["raw"]},
// URL
{test: /\.(jpg(\?.*)?)$/, loaders: ["url?limit=10000"]},
{test: /\.(jpeg(\?.*)?)$/, loaders: ["url?limit=10000"]},
{test: /\.(png(\?.*)?)$/, loaders: ["url?limit=10000"]},
{test: /\.(gif(\?.*)?)$/, loaders: ["url?limit=10000"]},
{test: /\.(svg(\?.*)?)$/, loaders: ["url?limit=10000"]},
{test: /\.(woff(\?.*)?)$/, loaders: ["url?limit=100000"]},
{test: /\.(woff2(\?.*)?)$/, loaders: ["url?limit=100000"]},
// FILE
{test: /\.(ttf(\?.*)?)$/, loaders: ["file"]},
{test: /\.(eot(\?.*)?)$/, loaders: ["file"]},
{test: /\.(wav(\?.*)?)$/, loaders: ["file"]},
{test: /\.(mp3(\?.*)?)$/, loaders: ["file"]},
// HTML
//{test: /\.(html(\?.*)?)$/, loaders: ["html"]},
{ test: /\.html$/, loaders: ["html"] },
// MARKDOWN
{test: /\.(md(\?.*)?)$/, loaders: ["html", "markdown"]},
// CSS
{test: /\.(css(\?.*)?)$/, loaders: ["style", "css"]}, // loader: ExtractTextPlugin.extract("style-loader", "css-loader")},
// LESS
{test: /\.(less(\?.*)?)$/, loaders: ["style", "css", "less"]}, // loader: ExtractTextPlugin.extract("style-loader", ["css-loader", "less-loader"])},
],
},
// Module resolving http://webpack.github.io/docs/configuration.html#resolve
resolve: {
// Abs. path with modules
root: __dirname + "/frontend",
// node_modules and like that
modulesDirectories: ["web_modules", "node_modules"],
},
// Loader resolving http://webpack.github.io/docs/configuration.html#resolveloader
resolveLoader: {
// Abs. path with loaders
root: __dirname + "/node_modules",
alias: {},
},
// Keep bundle dependencies http://webpack.github.io/docs/configuration.html#externals
externals: [],
// Plugins http://webpack.github.io/docs/list-of-plugins.html
plugins: [
function () {
this.plugin("done", function (stats) {
let jsonStats = stats.toJson({
chunkModules: true,
exclude: [
/node_modules[\\\/]react(-router)?[\\\/]/,
/node_modules[\\\/]items-store[\\\/]/
]
});
jsonStats.publicPath = "/public/";
require("fs").writeFileSync(__dirname + "/public/stats.json", JSON.stringify(jsonStats));
});
},
new Webpack.PrefetchPlugin("react"),
//new Webpack.PrefetchPlugin("react/lib/ReactComponentBrowserEnvironment"),
//new Webpack.optimize.CommonsChunkPlugin("commons", "commons.js?[chunkhash]"),
//new ExtractTextPlugin("[name].css?[contenthash]"),
//new Webpack.optimize.UglifyJsPlugin(),
//new Webpack.optimize.DedupePlugin(),
//new Webpack.DefinePlugin({
// "process.env": {
// NODE_ENV: JSON.stringify("production")
// }
//}),
//new Webpack.NoErrorsPlugin(),
],
// CLI mirror http://webpack.github.io/docs/configuration.html#devserver
devServer: {
stats: {
cached: false,
exclude: [
/node_modules[\\\/]react(-router)?[\\\/]/,
/node_modules[\\\/]items-store[\\\/]/
]
}
}
};