Skip to content

Commit

Permalink
feat: add new arg [--mode, -m], pass to vite.build
Browse files Browse the repository at this point in the history
  • Loading branch information
KusStar committed May 12, 2024
1 parent 272f61e commit 7fddda1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 14 additions & 2 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ cli.option('--entry --input -i', 'Use specified entry file, default is "index.ht

cli.option('--sourcemap ', 'use sourcemap to calculate sizes of modules. By idea it will present more accurate results, defaults is false')

cli.help()
cli.option('--sourcemap ', 'use sourcemap to calculate sizes of modules. By idea it will present more accurate results, defaults is false')

cli.help('--mode -m <mode>', 'set env mode, defaults to production')

const parsed = cli.parse()

const { template, t, h, help, output, o, open, config, c, entry, input, i, sourcemap } = parsed.options
const {
template, t,
h, help,
output, o,
open,
config, c,
entry, input, i,
sourcemap,
mode, m,
} = parsed.options

await start({
help: help || h,
Expand All @@ -39,5 +50,6 @@ await start({
open: open === true || open === 'true' || Number(open) > 0,
config: config || c,
entry: entry || input || i,
mode: mode || m,
sourcemap
})
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const start = async ({
output,
config,
entry,
sourcemap = false
sourcemap = false,
mode,
}) => {
if (help) {
return
Expand Down Expand Up @@ -68,6 +69,7 @@ const start = async ({

await build({
configFile: config,
mode: mode,
plugins: [
{
...visualizer({
Expand Down

0 comments on commit 7fddda1

Please sign in to comment.