mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 16:53:54 +01:00
[chore] fixing the ability to run dev-server
This commit is contained in:
parent
a98dd66e45
commit
c87621edd9
@ -93,7 +93,7 @@
|
||||
"url": "git+https://github.com/danielyxie/bitburner.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start:dev": "webpack-dev-server",
|
||||
"start:dev": "webpack-dev-server --progress --env.devServer --mode development",
|
||||
"build": "webpack --mode production",
|
||||
"build:dev": "webpack --mode development",
|
||||
"lint": "npm run lint:typescript & npm run lint:javascript & npm run lint:style",
|
||||
|
@ -3,10 +3,20 @@ var webpack = require('webpack');
|
||||
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = (env, argv) => ({
|
||||
module.exports = (env, argv) => {
|
||||
const isDevServer = (env || {}).devServer === true;
|
||||
const isDevelopment = argv.mode === 'development';
|
||||
const outputDirectory = isDevServer ? "dist-dev" : "dist";
|
||||
const entries = {};
|
||||
entries[`${outputDirectory}/engine`] = "./src/engine.js";
|
||||
if (!isDevServer) {
|
||||
entries["tests/tests"] = "./tests/index.js";
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': argv.mode === 'development' ? "\"development\"" : "\"production\""
|
||||
'process.env.NODE_ENV': isDevelopment ? "\"development\"" : "\"production\""
|
||||
}),
|
||||
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
|
||||
new webpack.ProvidePlugin({
|
||||
@ -18,14 +28,14 @@ module.exports = (env, argv) => ({
|
||||
$: "jquery"
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title: "Bitburner" + (argv.mode === 'development' ? ' - development' : ""),
|
||||
title: "Bitburner" + (isDevelopment ? ' - development' : ""),
|
||||
template: "src/index.html",
|
||||
favicon: "favicon.ico",
|
||||
googleAnalytics: {
|
||||
trackingId: 'UA-100157497-1'
|
||||
},
|
||||
meta: {},
|
||||
minify: argv.mode === 'development' ? false : {
|
||||
minify: isDevelopment ? false : {
|
||||
collapseBooleanAttributes: true,
|
||||
collapseInlineTagWhitespace: false,
|
||||
collapseWhitespace: false,
|
||||
@ -62,10 +72,7 @@ module.exports = (env, argv) => ({
|
||||
})
|
||||
],
|
||||
target: "web",
|
||||
entry: {
|
||||
"dist/engine": "./src/engine.js",
|
||||
"tests/tests": "./tests/index.js",
|
||||
},
|
||||
entry: entries,
|
||||
devtool: "source-map",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "./"),
|
||||
@ -100,20 +107,20 @@ module.exports = (env, argv) => ({
|
||||
concatenateModules: false,
|
||||
namedModules: false,
|
||||
namedChunks: false,
|
||||
minimize: argv.mode !== 'development',
|
||||
minimize: !isDevelopment,
|
||||
portableRecords: true,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: 'dist/vendor',
|
||||
name: `${outputDirectory}/vendor`,
|
||||
chunks: 'all'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
devServer: {
|
||||
publicPath: "/dist",
|
||||
publicPath: `/`,
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
@ -122,4 +129,5 @@ module.exports = (env, argv) => ({
|
||||
".js"
|
||||
]
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user