forked from NewSpring/Heighliner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
43 lines (40 loc) · 1.28 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
const validate = require("webpack-validator");
const nodeExternals = require("webpack-node-externals");
const DotenvPlugin = require("webpack-dotenv-plugin");
const NpmInstallPlugin = require("npm-install-webpack-plugin");
const { getIfUtils, removeEmpty } = require("webpack-config-utils");
const webpack = require("webpack");
const path = require("path");
const { ifProduction, ifNotProduction } = getIfUtils(process.env.NODE_ENV);
module.exports = validate({
entry: "./src/server.js",
target: "node",
output: {
path: path.resolve(__dirname, "./lib"),
filename: "server.js",
},
recordsPath: path.resolve(__dirname, "lib/_records"),
plugins: removeEmpty([
ifProduction(new webpack.optimize.DedupePlugin()),
ifProduction(new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false,
},
})),
ifNotProduction(new NpmInstallPlugin()),
ifNotProduction(new webpack.HotModuleReplacementPlugin()),
new webpack.NoErrorsPlugin(),
ifNotProduction(ifNotProduction() && new DotenvPlugin({ sample: "./.env.example" })),
]),
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: "babel",
},
],
},
externals: [nodeExternals()],
});