-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (90 loc) · 1.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
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const autoprefixer = require("autoprefixer");
const assetsPath = path.join(__dirname, "build", "assets");
const serverPath = path.join(__dirname, "build", "server");
const commonLoaders = [
];
module.exports = [
{
name: "browser",
entry: './app/entry.js',
output: {
path: assetsPath,
filename: 'bundle.js'
},
module: {
rules: commonLoaders.concat([
{
test: [/\.svg$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: "file-loader",
options: {
name: "[name].[ext]",
publicPath: url => url.replace(/build/, "")
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: "css-loader",
options: { importLoaders: 1 }
},
{
loader: "postcss-loader",
options: { plugins: [autoprefixer()] }
}
]
})
},
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: "babel-loader",
query: {presets: ["react-app"] }
},
])
},
plugins: [
new ExtractTextPlugin({
filename: "[name].css"
}),
function(compiler) {
this.plugin("done", function(stats) {
require("fs").writeFileSync(path.join(assetsPath, "stats.generated.json"), JSON.stringify(stats.toJson()));
});
}
]
},
{
name: "server-side rending",
entry: './server/page.js',
output: {
path: serverPath,
filename: "page.generator.js",
library: 'page',
libraryTarget: 'commonjs2'
},
module: {
rules: commonLoaders.concat([
{
test: [/\.svg$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: "file-loader",
options: {
name: "build/media/[name].[ext]",
publicPath: url => url.replace(/build/, ""),
emit: false
}
},
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: "babel-loader",
query: {presets: ["react-app"] }
},
{ test: /\.css$/, loader: "css-loader/locals" },
])
}
}
]