This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
executable file
·98 lines (92 loc) · 2.31 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
98
var webpack = require("webpack");
var path = require("path");
var argv = require("yargs").argv;
var package = require("./package.json");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var UglifyJsPlugin = require("uglifyjs-webpack-plugin");
var DEBUG = true;
if (process.env.NODE_ENV == "production") DEBUG = false;
// Paths
var basePath = path.resolve(__dirname);
var paths = {
base: basePath,
nodeModules: path.join(basePath, "node_modules"),
app: path.join(basePath, "src"),
index: path.join(basePath, "src/index.html"),
build: path.join(basePath, "docs")
};
var wConfig = {
entry: {
neosig: path.join(paths.app, "js/index")
},
output: {
filename: "[name]-" + package.version + ".js",
path: paths.build
},
module: {
rules: [
{
test: /\.js$/,
loader: "eslint-loader",
enforce: "pre",
include: path.resolve("src")
},
// Enable ES6 support
{
test: /\.js?$/,
exclude: [paths.nodeModules],
loaders: ["babel-loader"]
},
//load sigma as global
{ test: /.*\/sigma.+\.js$/, use: "imports-loader?this=>window" }
]
},
externals: {
neo4j: "neo4j"
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
template: "./src/index.html",
inject: "head"
})
],
cache: DEBUG,
devtool: DEBUG ? "#inline-source-map" : false
};
if (!DEBUG)
wConfig.plugins.push(
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: process.env.NODE_ENV
}
})
);
if (DEBUG) {
// Entry points - In production we'll have only the `main.jsx` entry.
// However in DEBUG, we'll enable Webpacks "Hot Module Replacement"
// functionality for fast development!
var entries = {};
var defaultEntries = [
"webpack-dev-server/client?http://localhost:8080",
"webpack/hot/only-dev-server"
];
// Adding default entries
entries["neosig"] = defaultEntries.concat(wConfig.entry.neosig);
wConfig.entry = entries;
// Hot Module Replacement ftw
wConfig.plugins = wConfig.plugins.concat([
new webpack.HotModuleReplacementPlugin(),
new UglifyJsPlugin({
test: /\.js($|\?)/i,
uglifyOptions: {
comments: false
}
})
]);
wConfig.devServer = {
hot: true,
disableHostCheck: true
};
}
module.exports = wConfig;