-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
61 lines (58 loc) · 1.48 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
"use strict";
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const failPlugin = require("webpack-fail-plugin");
const HTMLInlineSourcePlugin = require("html-webpack-inline-source-plugin");
const HTMLPlugin = require("html-webpack-plugin");
const path = require("path");
const webpack = require("webpack");
// Always enabled plugins
const plugins = [
// Extract CSS files to the 'bundle.css'.
new ExtractTextPlugin("build.css"),
new HTMLPlugin({
title: "Pen",
inlineSource: ".(js|css)$"
}),
new HTMLInlineSourcePlugin(),
// This plugin should be always required. See https://github.com/webpack/webpack/issues/708
failPlugin
];
// Production only plugins
if (process.env.NODE_ENV === "production") {
plugins.push(
// Pass the 'NODE_ENV=production' environment variable to the child processes.
new webpack.DefinePlugin({
"process.env": { NODE_ENV: JSON.stringify("production") }
})
);
}
// Configs
module.exports = {
entry: "./main.js",
context: path.resolve(__dirname, "src/frontend"),
output: {
filename: "build.js",
path: path.resolve(__dirname, "dist")
},
module: {
loaders: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.json$/,
use: "json-loader"
},
{
test: /\.js$/,
exclude: /node_modules/,
use: "babel-loader"
}
]
},
plugins
};