Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
85 lines (82 loc) · 2.25 KB
/
Copy pathwebpack.config.js
File metadata and controls
85 lines (82 loc) · 2.25 KB
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
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var UglifyJsPlugin = require("uglifyjs-webpack-plugin");
var webpack = require("webpack");
var plugins = [
new ExtractTextPlugin({ filename: "../css/[name].bundle.css", allChunks: true }),
new webpack.optimize.CommonsChunkPlugin({ name: "common", filename: "common.bundle.js" }),
];
if (process.env.NODE_ENV === "production") {
plugins.push(
new UglifyJsPlugin(),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production"),
})
);
} else {
plugins.push(
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("development"),
})
);
}
module.exports = {
entry: {
common: ["react", "react-dom", "./src/client/layout/page.js"],
main: "./src/client/pages/main/browser.js",
book: "./src/client/pages/book/browser.js",
conference: "./src/client/pages/conference/browser.js",
school: "./src/client/pages/school/browser.js",
consulting: "./src/client/pages/consulting/browser.js",
articles: "./src/client/pages/articles/browser.js",
about: "./src/client/pages/about/browser.js",
},
output: {
path: path.join(__dirname, "./dist/static/js"),
filename: "[name].bundle.js",
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: "babel-loader",
query: {
babelrc: false,
presets: ["react", "env"],
},
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: "css-loader",
options: {
modules: true,
localIdentName: "[local]_[hash:base64:5]",
imports: true,
},
},
],
fallback: "style-loader",
}),
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: {
loader: "file-loader",
options: {
name: "[name]__[hash].[ext]",
outputPath: "../assets/",
useRelativePath: false,
},
},
},
],
},
plugins: plugins,
resolve: {
modules: [path.join(__dirname, "src"), "node_modules"],
extensions: [".js", ".jsx"],
},
};