2018-03-21 16:56:30 +01:00
|
|
|
var path = require('path');
|
2018-02-24 23:55:06 +01:00
|
|
|
var webpack = require('webpack');
|
|
|
|
|
2018-06-13 19:38:22 +02:00
|
|
|
module.exports = (env, argv) => ({
|
2018-02-24 23:55:06 +01:00
|
|
|
plugins: [
|
2018-06-13 19:38:22 +02:00
|
|
|
new webpack.DefinePlugin({
|
2018-06-13 21:26:15 +02:00
|
|
|
'process.env.NODE_ENV': argv.mode === 'development' ? "\"development\"" : "\"production\""
|
2018-06-13 19:38:22 +02:00
|
|
|
}),
|
|
|
|
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
// Automtically detect jQuery and $ as free var in modules
|
|
|
|
// and inject the jquery library
|
|
|
|
// This is required by many jquery plugins
|
|
|
|
jquery: "jquery",
|
|
|
|
jQuery: "jquery",
|
|
|
|
$: "jquery"
|
|
|
|
})
|
2018-02-24 23:55:06 +01:00
|
|
|
],
|
2018-03-21 16:56:30 +01:00
|
|
|
target: "web",
|
2018-05-05 05:29:22 +02:00
|
|
|
entry: {
|
2018-06-08 17:51:48 +02:00
|
|
|
"dist/engine": "./src/engine.js",
|
|
|
|
"tests/tests": "./tests/index.js",
|
2018-05-05 05:29:22 +02:00
|
|
|
},
|
2018-06-06 18:49:00 +02:00
|
|
|
devtool: "source-map",
|
2018-02-24 23:55:06 +01:00
|
|
|
output: {
|
2018-06-08 17:51:48 +02:00
|
|
|
path: path.resolve(__dirname, "./"),
|
2018-06-06 18:49:00 +02:00
|
|
|
filename: "[name].bundle.js"
|
2018-02-24 23:55:06 +01:00
|
|
|
},
|
|
|
|
module: {
|
2018-06-14 05:38:35 +02:00
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
}
|
|
|
|
]
|
2018-03-21 16:56:30 +01:00
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
removeAvailableModules: true,
|
|
|
|
removeEmptyChunks: true,
|
|
|
|
mergeDuplicateChunks: true,
|
|
|
|
flagIncludedChunks: true,
|
|
|
|
occurrenceOrder: true,
|
|
|
|
sideEffects: true,
|
2018-07-09 15:38:37 +02:00
|
|
|
providedExports: true,
|
2018-07-09 15:50:23 +02:00
|
|
|
usedExports: true,
|
2018-03-21 16:56:30 +01:00
|
|
|
concatenateModules: false,
|
|
|
|
namedModules: false,
|
|
|
|
namedChunks: false,
|
2018-07-09 16:59:05 +02:00
|
|
|
minimize: argv.mode !== 'development',
|
2018-07-09 18:25:08 +02:00
|
|
|
portableRecords: true,
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: 'dist/vendor',
|
|
|
|
chunks: 'all'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-05 05:36:39 +02:00
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
publicPath: "/dist",
|
2018-06-14 05:38:35 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [
|
|
|
|
".tsx",
|
|
|
|
".ts",
|
|
|
|
".js"
|
|
|
|
]
|
2018-02-24 23:55:06 +01:00
|
|
|
}
|
2018-06-13 19:38:22 +02:00
|
|
|
});
|