Build bundle analyzer and no-auth start commands.

build-report: uses webpack-bundle-analzer for interactive bundle size
explorer.
start-noauth: running locally without endpoint authentication enabled.
This commit is contained in:
2020-12-06 20:43:10 +01:00
parent c4c74ca3ef
commit 2fa0c1085c
3 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
const mustBeAuthenticated = (req, res, next) => { const mustBeAuthenticated = (req, res, next) => {
if (process.env.NODE_ENV == "development") { if (process.env.NODE_ENV == "development") {
console.info(`Restricted endpoint ${req.originalUrl}, but running in dev mode.`) console.info(`Restricted endpoint ${req.originalUrl}, allowing with environment development.`)
req.isAuthenticated = () => true;
return next(); return next();
} }

View File

@@ -71,12 +71,12 @@ const webpackConfig = merge(commonConfig(false), {
if (!isProd) { if (!isProd) {
webpackConfig.devtool = "source-map"; webpackConfig.devtool = "source-map";
}
if (process.env.npm_config_report) { if (process.env.BUILD_REPORT) {
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin; .BundleAnalyzerPlugin;
webpackConfig.plugins.push(new BundleAnalyzerPlugin()); webpackConfig.plugins.push(new BundleAnalyzerPlugin());
}
} }
module.exports = webpackConfig; module.exports = webpackConfig;

View File

@@ -4,12 +4,12 @@
"description": "", "description": "",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
"build": "cross-env NODE_ENV=production webpack --progress",
"build-report": "cross-env NODE_ENV=production BUILD_REPORT=true webpack --progress",
"dev": "yarn webpack serve --mode development --env development",
"start": "node server.js", "start": "node server.js",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules", "start-noauth": "cross-env NODE_ENV=development node server.js",
"dev": "cross-env NODE_ENV=development webpack-dev-server",
"start-dev": "cross-env NODE_ENV=development node server.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
"build": "cross-env NODE_ENV=production webpack --hide-modules"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",