Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/vuepress/bin/vuepress-vite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env node

import { viteBundler } from '@vuepress/bundler-vite'
import { cli } from '@vuepress/cli'
import process from 'node:process'

// Set `NODE_ENV` before loading the bundler, because some of its dependencies
// (e.g. `vue`) select their development or production builds according to
// `NODE_ENV` when they are loaded, which is earlier than the `dev` / `build`
// command sets it. Keep the defaults in sync with the commands.
const command = process.argv[2]
if (command === 'dev') {
process.env.NODE_ENV ??= 'development'
} else if (command === 'build') {
process.env.NODE_ENV ??= 'production'
}

const { viteBundler } = await import('@vuepress/bundler-vite')
const { cli } = await import('@vuepress/cli')

cli({ bundler: viteBundler() })
17 changes: 15 additions & 2 deletions packages/vuepress/bin/vuepress-webpack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env node

import { webpackBundler } from '@vuepress/bundler-webpack'
import { cli } from '@vuepress/cli'
import process from 'node:process'

// Set `NODE_ENV` before loading the bundler, because some of its dependencies
// (e.g. `vue`) select their development or production builds according to
// `NODE_ENV` when they are loaded, which is earlier than the `dev` / `build`
// command sets it. Keep the defaults in sync with the commands.
const command = process.argv[2]
if (command === 'dev') {
process.env.NODE_ENV ??= 'development'
} else if (command === 'build') {
process.env.NODE_ENV ??= 'production'
}

const { webpackBundler } = await import('@vuepress/bundler-webpack')
const { cli } = await import('@vuepress/cli')

cli({ bundler: webpackBundler() })
Loading