GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — :sparkles: optional start modes · nullstack/nullstack@661916c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • scripts
    • index.js
  • server
    • prerender.js
  • tests
    • package.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎scripts/index.js‎

Copy file name to clipboardExpand all lines: scripts/index.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function getClientCompiler(options) {
2727
return webpack(getConfig(options)[1])
2828
}
2929

30-
async function start({ input, port, env }) {
30+
async function start({ input, port, env, mode = 'ssr', hot }) {
3131
const environment = 'development';
3232
const serverCompiler = getServerCompiler({ environment, input });
3333
let clientStarted = false
@@ -37,7 +37,7 @@ async function start({ input, port, env }) {
3737
}
3838
dotenv.config({ path: envPath })
3939
port ??= process.env['NULLSTACK_SERVER_PORT'] || process.env['PORT'] || 3000
40-
process.env['NULLSTACK_ENVIRONMENT_MODE'] = 'spa'
40+
process.env['NULLSTACK_ENVIRONMENT_MODE'] = mode
4141
console.log(` 🚀️ Starting your application in ${environment} mode...`);
4242
const WebpackDevServer = require('webpack-dev-server');
4343
const { setLogLevel } = require('webpack/hot/log')
@@ -53,7 +53,7 @@ async function start({ input, port, env }) {
5353
if (!clientStarted) {
5454
clientStarted = true
5555
const devServerOptions = {
56-
hot: true,
56+
hot: !!hot,
5757
open: false,
5858
devMiddleware: {
5959
index: false
@@ -114,18 +114,20 @@ program
114114
.command('start')
115115
.alias('s')
116116
.description('Start application in development environment')
117+
.addOption(new program.Option('-m, --mode <mode>', 'Build production bundles').choices(['ssr', 'spa']))
117118
.option('-p, --port <port>', 'Port number to run the server')
118119
.option('-i, --input <input>', 'Path to project that will be started')
119120
.option('-o, --output <output>', 'Path to build output folder')
120121
.option('-e, --env <name>', 'Name of the environment file that should be loaded')
122+
.option('--hot', 'Enable hot module replacement')
121123
.helpOption('-h, --help', 'Learn more about this command')
122124
.action(start)
123125

124126
program
125127
.command('build')
126128
.alias('b')
127129
.description('Build application for production environment')
128-
.addOption(new program.Option('-m, --mode <mode>', 'Build production bundles').choices(buildModes))
130+
.addOption(new program.Option('-m, --mode <mode>', 'Build production bundles').choices(['ssr', 'spa', 'ssg']))
129131
.option('-i, --input <input>', 'Path to project that will be built')
130132
.option('-o, --output <output>', 'Path to build output folder')
131133
.option('-c, --cache', 'Cache build results in .production folder')
Collapse file

‎server/prerender.js‎

Copy file name to clipboardExpand all lines: server/prerender.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function prerender(request, response) {
3636
scope.plugins = loadPlugins(scope);
3737

3838
try {
39-
if (environment.production) {
39+
if (environment.production || environment.mode !== 'spa') {
4040
const tree = await generateTree(generator.starter(), scope);
4141
scope.body = render(tree, scope);
4242
}
Collapse file

‎tests/package.json‎

Copy file name to clipboardExpand all lines: tests/package.json
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"purgecss-webpack-plugin": "^4.1.3"
1414
},
1515
"scripts": {
16-
"start": "npx nullstack start --input=./tests --port=6969 --env=test",
17-
"build": "npx nullstack build --input=./tests --mode=ssr --env=test",
16+
"start": "npx nullstack start --input=./tests --port=6969 --env=test --mode=spa --hot",
17+
"build": "npx nullstack build --input=./tests --env=test",
1818
"test": "npm run build && jest",
1919
"script": "node src/scripts/run.js"
2020
}
21-
}
21+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.