forked from webpack/react-webpack-server-side-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
52 lines (50 loc) · 1.25 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
var path = require("path");
var commonLoaders = [
{ test: /\.js$/, loader: "jsx-loader" },
{ test: /\.png$/, loader: "url-loader" },
{ test: /\.jpg$/, loader: "file-loader" },
];
var assetsPath = path.join(__dirname, "public", "assets");
var publicPath = "assets/";
module.exports = [
{
// The configuration for the client
name: "browser",
entry: "./app/entry.js",
output: {
path: assetsPath,
filename: "[hash].js",
publicPath: publicPath
},
module: {
loaders: commonLoaders.concat([
{ test: /\.css$/, loader: "style-loader!css-loader" },
])
},
plugins: [
function(compiler) {
this.plugin("done", function(stats) {
require("fs").writeFileSync(path.join(__dirname, "server", "stats.generated.json"), JSON.stringify(stats.toJson()));
});
}
]
},
{
// The configuration for the server-side rendering
name: "server-side rendering",
entry: "./server/page.js",
target: "node",
output: {
path: assetsPath,
filename: "../../server/page.generated.js",
publicPath: publicPath,
libraryTarget: "commonjs2"
},
externals: /^[a-z\-0-9]+$/,
module: {
loaders: commonLoaders.concat([
{ test: /\.css$/, loader: path.join(__dirname, "server", "style-collector") + "!css-loader" },
])
}
}
];