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-07-11 17:19:36 +02:00
|
|
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2018-08-30 16:43:18 +02:00
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
2018-02-24 23:55:06 +01:00
|
|
|
|
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-07-11 17:19:36 +02:00
|
|
|
}),
|
2018-08-30 16:43:18 +02:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
title: "Bitburner" + (argv.mode === 'development' ? ' - development' : ""),
|
|
|
|
template: "src/index.html",
|
|
|
|
favicon: "favicon.ico",
|
2018-08-30 17:08:08 +02:00
|
|
|
googleAnalytics: {
|
|
|
|
trackingId: 'UA-100157497-1'
|
|
|
|
},
|
2018-08-30 16:43:18 +02:00
|
|
|
meta: {},
|
|
|
|
minify: argv.mode === 'development' ? false : {
|
|
|
|
collapseBooleanAttributes: true,
|
|
|
|
collapseInlineTagWhitespace: false,
|
|
|
|
collapseWhitespace: false,
|
|
|
|
conservativeCollapse: false,
|
|
|
|
html5: true,
|
|
|
|
includeAutoGeneratedTags: false,
|
|
|
|
keepClosingSlash: true,
|
|
|
|
minifyCSS: false,
|
|
|
|
minifyJS: false,
|
|
|
|
minifyURLs: false,
|
|
|
|
preserveLineBreaks: false,
|
|
|
|
preventAttributesEscaping: false,
|
|
|
|
processConditionalComments: false,
|
|
|
|
quoteCharacter: "\"",
|
|
|
|
removeAttributeQuotes: false,
|
|
|
|
removeComments: false,
|
|
|
|
removeEmptyAttributes: false,
|
|
|
|
removeEmptyElements: false,
|
|
|
|
removeOptionalTags: false,
|
|
|
|
removeScriptTypeAttributes: false,
|
|
|
|
removeStyleLinkTypeAttributes: false,
|
|
|
|
removeTagWhitespace: false,
|
|
|
|
sortAttributes: false,
|
|
|
|
sortClassName: false,
|
|
|
|
useShortDoctype: false
|
|
|
|
},
|
|
|
|
excludeChunks: [
|
|
|
|
"tests/tests"
|
|
|
|
]
|
|
|
|
}),
|
2018-07-11 17:19:36 +02:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name].css",
|
|
|
|
chunkFilename: "[id].css"
|
2018-06-13 19:38:22 +02:00
|
|
|
})
|
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-07-11 17:19:36 +02:00
|
|
|
},
|
|
|
|
{
|
2018-07-13 22:13:49 +02:00
|
|
|
test: /\.s?css$/,
|
2018-07-11 17:19:36 +02:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
2018-07-13 22:13:49 +02:00
|
|
|
"css-loader",
|
|
|
|
"sass-loader"
|
2018-07-11 17:19:36 +02:00
|
|
|
]
|
2018-07-13 22:13:49 +02:00
|
|
|
},
|
2018-06-14 05:38:35 +02:00
|
|
|
]
|
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
|
|
|
});
|