2018-03-21 11:56:30 -04:00
|
|
|
var path = require('path');
|
2018-02-24 16:55:06 -06:00
|
|
|
var webpack = require('webpack');
|
2018-07-11 11:19:36 -04:00
|
|
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2018-02-24 16:55:06 -06:00
|
|
|
|
2018-06-13 12:38:22 -05:00
|
|
|
module.exports = (env, argv) => ({
|
2018-02-24 16:55:06 -06:00
|
|
|
plugins: [
|
2018-06-13 12:38:22 -05:00
|
|
|
new webpack.DefinePlugin({
|
2018-06-13 14:26:15 -05:00
|
|
|
'process.env.NODE_ENV': argv.mode === 'development' ? "\"development\"" : "\"production\""
|
2018-06-13 12:38:22 -05: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-07-11 11:19:36 -04:00
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name].css",
|
|
|
|
chunkFilename: "[id].css"
|
2018-06-13 12:38:22 -05:00
|
|
|
})
|
2018-02-24 16:55:06 -06:00
|
|
|
],
|
2018-03-21 11:56:30 -04:00
|
|
|
target: "web",
|
2018-05-04 23:29:22 -04:00
|
|
|
entry: {
|
2018-06-08 10:51:48 -05:00
|
|
|
"dist/engine": "./src/engine.js",
|
|
|
|
"tests/tests": "./tests/index.js",
|
2018-05-04 23:29:22 -04:00
|
|
|
},
|
2018-06-06 12:49:00 -04:00
|
|
|
devtool: "source-map",
|
2018-02-24 16:55:06 -06:00
|
|
|
output: {
|
2018-06-08 10:51:48 -05:00
|
|
|
path: path.resolve(__dirname, "./"),
|
2018-06-06 12:49:00 -04:00
|
|
|
filename: "[name].bundle.js"
|
2018-02-24 16:55:06 -06:00
|
|
|
},
|
|
|
|
module: {
|
2018-06-13 23:38:35 -04:00
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
exclude: /node_modules/
|
2018-07-11 11:19:36 -04:00
|
|
|
},
|
|
|
|
{
|
2018-07-13 16:13:49 -04:00
|
|
|
test: /\.s?css$/,
|
2018-07-11 11:19:36 -04:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
2018-07-13 16:13:49 -04:00
|
|
|
"css-loader",
|
|
|
|
"sass-loader"
|
2018-07-11 11:19:36 -04:00
|
|
|
]
|
2018-07-13 16:13:49 -04:00
|
|
|
},
|
2018-06-13 23:38:35 -04:00
|
|
|
]
|
2018-03-21 11:56:30 -04:00
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
removeAvailableModules: true,
|
|
|
|
removeEmptyChunks: true,
|
|
|
|
mergeDuplicateChunks: true,
|
|
|
|
flagIncludedChunks: true,
|
|
|
|
occurrenceOrder: true,
|
|
|
|
sideEffects: true,
|
2018-07-09 09:38:37 -04:00
|
|
|
providedExports: true,
|
2018-07-09 09:50:23 -04:00
|
|
|
usedExports: true,
|
2018-03-21 11:56:30 -04:00
|
|
|
concatenateModules: false,
|
|
|
|
namedModules: false,
|
|
|
|
namedChunks: false,
|
2018-07-09 10:59:05 -04:00
|
|
|
minimize: argv.mode !== 'development',
|
2018-07-09 12:25:08 -04:00
|
|
|
portableRecords: true,
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: 'dist/vendor',
|
|
|
|
chunks: 'all'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-04 23:36:39 -04:00
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
publicPath: "/dist",
|
2018-06-13 23:38:35 -04:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [
|
|
|
|
".tsx",
|
|
|
|
".ts",
|
|
|
|
".js"
|
|
|
|
]
|
2018-02-24 16:55:06 -06:00
|
|
|
}
|
2018-06-13 12:38:22 -05:00
|
|
|
});
|