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