-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
90 lines (86 loc) · 2.6 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
/* eslint "no-console": 0 */
/* eslint "strict": 0 */
"use strict";
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
// Build modules array from package.json
const packageJson = require("./package.json");
const modules = [];
for (let moduleName in packageJson.dependencies) {
if (packageJson.dependencies.hasOwnProperty(moduleName)) {
// Ignore font-awesome as it is not a js lib
if (moduleName === "font-awesome") {continue; }
modules.push(moduleName);
}
}
let config = {
context: __dirname,
devtool: "source-map",
entry: {
app: "./app/scripts/entry.js",
vendor: modules
},
output: {
path: path.join(__dirname, "build"),
publicPath: "/",
filename: "[name].[contenthash].js"
},
module: {
noParse: [],
loaders: [{
test: /\.html$/,
loader: "html-loader",
exclude: /node_modules/
}, {
test: /\.jpe?g$|\.gif$|\.png$/i,
loader: "url-loader?limit=10000",
exclude: /node_modules/
}, {
test: /\.scss$/,
loader: "style-loader!css-loader?sourceMap!autoprefixer?browsers=last 2 version!sass-loader",
exclude: /node_modules/
}, {
test: /\.jsx?$/,
loaders: ["react-hot-loader", "babel-loader?presets[]=es2015,presets[]=react"],
exclude: /node_modules/,
include: path.join(__dirname, "app")
}, {
test: /\.svg$|\.woff2?$|\.ttf$|\.eot$/,
loader: "file"
}]
},
plugins: [
new CleanWebpackPlugin(["build"]),
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.[contenthash].js"),
new HtmlWebpackPlugin({filename: "index.html", template: "./app/index.html", inject: true}),
new webpack.DefinePlugin({"process.env.NODE_ENV": JSON.stringify("development")})
],
resolve: {
alias: {},
root: [
path.join(__dirname, "app"),
path.join(__dirname, "app/scripts")
],
modulesDirectories: [
"./node_modules"
],
extensions: ["", ".js", ".jsx", ".scss", ".html"]
},
stats: {
colors: true, modules: true, reasons: true
},
watchOptions: {
poll: true
},
devServer: {
port: 1337,
host: "0.0.0.0",
contentBase: "./build",
historyApiFallback: {
index: "/index.html"
}
}
};
module.exports = config;