thelounge/webpack.config.js

90 lines
1.7 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
let config = {
2016-12-18 15:53:28 +00:00
entry: {
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
"js/bundle.vendor.js": [
2016-12-18 15:53:28 +00:00
"handlebars/runtime",
"jquery",
"jquery-ui/ui/widgets/sortable",
"moment",
2016-12-18 15:53:28 +00:00
"mousetrap",
"socket.io-client",
"urijs",
],
},
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: [
new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js")
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;