hardlounge/webpack.config.js

87 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-12-18 15:53:28 +00:00
"use strict";
const webpack = require("webpack");
const path = require("path");
// ********************
// Common configuration
// ********************
2016-12-18 15:53:28 +00:00
const config = {
2016-12-18 15:53:28 +00:00
entry: {
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
2016-12-18 15:53:28 +00:00
},
devtool: "source-map",
output: {
path: path.resolve(__dirname, "client"),
filename: "[name]",
2016-12-18 15:53:28 +00:00
publicPath: "/"
},
module: {
2017-02-17 15:01:20 +00:00
rules: [
2016-12-18 15:53:28 +00:00
{
test: /\.js$/,
include: [
path.resolve(__dirname, "client"),
],
2017-02-17 15:01:20 +00:00
use: {
loader: "babel-loader",
options: {
presets: [
2017-04-21 21:27:18 +00:00
["env", {
targets: {
browsers: "last 2 versions"
}
}]
2017-02-17 15:01:20 +00:00
]
}
2016-12-18 15:53:28 +00:00
}
},
{
test: /\.tpl$/,
include: [
path.resolve(__dirname, "client/views"),
],
2017-02-17 15:01:20 +00:00
use: {
loader: "handlebars-loader",
options: {
helperDirs: [
path.resolve(__dirname, "client/js/libs/handlebars")
],
extensions: [
".tpl"
],
}
2016-12-18 15:53:28 +00:00
}
},
]
},
2017-03-19 08:02:39 +00:00
externals: {
json3: "JSON", // socket.io uses json3.js, but we do not target any browsers that need it
},
2016-12-18 15:53:28 +00:00
plugins: [
// socket.io uses debug, we don't need it
new webpack.NormalModuleReplacementPlugin(/debug/, path.resolve(__dirname, "scripts/noop.js")),
2017-08-25 15:58:16 +00:00
// automatically split all vendor dependencies into a separate bundle
new webpack.optimize.CommonsChunkPlugin({
name: "js/bundle.vendor.js",
minChunks: (module) => module.context && module.context.indexOf("node_modules") !== -1
})
2016-12-18 15:53:28 +00:00
]
};
// *********************************
// Production-specific configuration
// *********************************
if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
2017-02-17 15:01:20 +00:00
comments: false
}));
2017-02-17 15:01:20 +00:00
} else {
console.log("Building in development mode, bundles will not be minified.");
}
module.exports = config;