thelounge/webpack.config.js

92 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"),
"js/bundle.vendor.js": [
2016-12-18 16:53:28 +01:00
"handlebars/runtime",
"jquery",
"jquery-textcomplete",
2016-12-18 16:53:28 +01:00
"jquery-ui/ui/widgets/sortable",
"moment",
2016-12-18 16:53:28 +01:00
"mousetrap",
"socket.io-client",
"urijs",
"fuzzy",
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: [
new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js")
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
}));
2017-02-17 16:01:20 +01:00
} else {
console.log("Building in development mode, bundles will not be minified.");
}
module.exports = config;