-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·97 lines (93 loc) · 2.9 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
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var webpack = require("webpack");
var assetsPath = path.join(__dirname, "public", "assets");
var publicPath = "assets/";
var commonLoaders = [
{
test: /\.jsx$/, loader: "babel-loader?stage=0"
},
{
test: /\.js$/,
loader: "babel-loader?stage=0",
include: path.join(__dirname, "app")
},
{ test: /\.png$/, loader: "url-loader" },
{ test: /\.jpg$/, loader: "file-loader" },
{ test: /\.html$/, loader: "html-loader" }
];
module.exports = [
{
// The configuration for the client
name: "browser",
context: path.join(__dirname, "app"),
entry: {
app: "./app"
},
output: {
// The output directory as absolute path
path: assetsPath,
filename: "[name].js",
// The output path from the view of the Javascript
publicPath: publicPath
},
node: {
// To fix webpack error from `react-validation-mixin` module
dns: "empty",
net: "empty"
},
module: {
preLoaders: [{
test: /\.js$|.jsx$/,
exclude: /node_modules/,
loaders: ["eslint"]
}],
loaders: commonLoaders.concat([
{ test: /\.css$/, loader: "style!css" },
{ test: /\.scss$/,
loader: ExtractTextPlugin.extract("css?sourceMap!sass?sourceMap&outputStyle=expanded" +
"&includePaths[]=" + (path.resolve(__dirname, "./bower_components")) +
"&includePaths[]=" + (path.resolve(__dirname, "./node_modules")))
}
])
},
resolve: {
modulesDirectories: [
"app", "node_modules"
]
},
plugins: [
// extract inline css from modules into separate files
new ExtractTextPlugin("styles/main.css")
]
}, {
// The configuration for the server-side rendering
name: "server-side rendering",
context: path.join(__dirname, "app"),
entry: {
app: "./app",
header: "./elements/Header.react"
},
target: "node",
output: {
// The output directory as absolute path
path: assetsPath,
filename: "[name].server.js",
// The output path from the view of the Javascript
publicPath: publicPath,
libraryTarget: "commonjs2"
},
externals: /^[a-z\-0-9]+$/,
module: {
loaders: commonLoaders
},
resolve: {
modulesDirectories: [
"app", "node_modules"
]
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/\.(css|scss)$/, "node-noop")
]
}
];