thelounge/webpack.config.js

85 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-12-18 16:53:28 +01:00
"use strict";
const webpack = require("webpack");
const path = require("path");
// ********************
// Common configuration
// ********************
2016-12-18 16:53:28 +01:00
const config = {
2016-12-18 16:53:28 +01:00
entry: {
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
2016-12-18 16:53:28 +01:00
},
devtool: "source-map",
output: {
path: path.resolve(__dirname, "client"),
filename: "[name]",
2016-12-18 16:53:28 +01:00
publicPath: "/"
},
module: {
2017-02-17 16:01:20 +01:00
rules: [
2016-12-18 16:53:28 +01:00
{
test: /\.js$/,
include: [
path.resolve(__dirname, "client"),
],
2017-02-17 16:01:20 +01:00
use: {
loader: "babel-loader",
options: {
presets: [
2017-04-21 23:27:18 +02:00
["env", {
targets: {
browsers: "last 2 versions"
}
}]
2017-02-17 16:01:20 +01:00
]
}
2016-12-18 16:53:28 +01:00
}
},
{
test: /\.tpl$/,
include: [
path.resolve(__dirname, "client/views"),
],
2017-02-17 16:01:20 +01:00
use: {
loader: "handlebars-loader",
options: {
helperDirs: [
path.resolve(__dirname, "client/js/libs/handlebars")
],
extensions: [
".tpl"
],
}
2016-12-18 16:53:28 +01:00
}
},
]
},
2017-03-19 09:02:39 +01:00
externals: {
json3: "JSON", // socket.io uses json3.js, but we do not target any browsers that need it
},
2016-12-18 16:53:28 +01:00
plugins: [
// socket.io uses debug, we don't need it
new webpack.NormalModuleReplacementPlugin(/debug/, path.resolve(__dirname, "scripts/noop.js")),
2017-08-25 17:58:16 +02: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 16:53:28 +01:00
]
};
// *********************************
// Production-specific configuration
// *********************************
if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
2017-02-17 16:01:20 +01:00
comments: false
}));
}
module.exports = config;