mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
[chore] fixing the ability to run dev-server
This commit is contained in:
parent
ab23d34a7a
commit
24b5a5dd31
@ -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,123 +3,131 @@ var webpack = require('webpack');
|
||||
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = (env, argv) => ({
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': argv.mode === 'development' ? "\"development\"" : "\"production\""
|
||||
}),
|
||||
// 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"
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title: "Bitburner" + (argv.mode === 'development' ? ' - development' : ""),
|
||||
template: "src/index.html",
|
||||
favicon: "favicon.ico",
|
||||
googleAnalytics: {
|
||||
trackingId: 'UA-100157497-1'
|
||||
},
|
||||
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"
|
||||
]
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "[name].css",
|
||||
chunkFilename: "[id].css"
|
||||
})
|
||||
],
|
||||
target: "web",
|
||||
entry: {
|
||||
"dist/engine": "./src/engine.js",
|
||||
"tests/tests": "./tests/index.js",
|
||||
},
|
||||
devtool: "source-map",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "./"),
|
||||
filename: "[name].bundle.js"
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
"css-loader",
|
||||
"sass-loader"
|
||||
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': isDevelopment ? "\"development\"" : "\"production\""
|
||||
}),
|
||||
// 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"
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title: "Bitburner" + (isDevelopment ? ' - development' : ""),
|
||||
template: "src/index.html",
|
||||
favicon: "favicon.ico",
|
||||
googleAnalytics: {
|
||||
trackingId: 'UA-100157497-1'
|
||||
},
|
||||
meta: {},
|
||||
minify: isDevelopment ? 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"
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
removeAvailableModules: true,
|
||||
removeEmptyChunks: true,
|
||||
mergeDuplicateChunks: true,
|
||||
flagIncludedChunks: true,
|
||||
occurrenceOrder: true,
|
||||
sideEffects: true,
|
||||
providedExports: true,
|
||||
usedExports: true,
|
||||
concatenateModules: false,
|
||||
namedModules: false,
|
||||
namedChunks: false,
|
||||
minimize: argv.mode !== 'development',
|
||||
portableRecords: true,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: 'dist/vendor',
|
||||
chunks: 'all'
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "[name].css",
|
||||
chunkFilename: "[id].css"
|
||||
})
|
||||
],
|
||||
target: "web",
|
||||
entry: entries,
|
||||
devtool: "source-map",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "./"),
|
||||
filename: "[name].bundle.js"
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
"css-loader",
|
||||
"sass-loader"
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
removeAvailableModules: true,
|
||||
removeEmptyChunks: true,
|
||||
mergeDuplicateChunks: true,
|
||||
flagIncludedChunks: true,
|
||||
occurrenceOrder: true,
|
||||
sideEffects: true,
|
||||
providedExports: true,
|
||||
usedExports: true,
|
||||
concatenateModules: false,
|
||||
namedModules: false,
|
||||
namedChunks: false,
|
||||
minimize: !isDevelopment,
|
||||
portableRecords: true,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: `${outputDirectory}/vendor`,
|
||||
chunks: 'all'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
devServer: {
|
||||
publicPath: `/`,
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
".tsx",
|
||||
".ts",
|
||||
".js"
|
||||
]
|
||||
}
|
||||
},
|
||||
devServer: {
|
||||
publicPath: "/dist",
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
".tsx",
|
||||
".ts",
|
||||
".js"
|
||||
]
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user