Skip to content

Commit

Permalink
feat(server): support force options
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 27, 2021
1 parent c42e795 commit 3311833
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"tsup": "4.11.1",
"typescript": "^4.3.2",
"vite": "^2.3.4",
"vite-plugin-windicss": "^0.16.2",
"vite-plugin-windicss": "^0.16.3",
"zx": "^1.14.0"
}
}
9 changes: 8 additions & 1 deletion packages/slidev/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ cli.command(
choices: ['error', 'warn', 'info', 'silent'],
describe: 'log level',
})
.option('force', {
alias: 'f',
default: false,
type: 'boolean',
describe: 'force the optimizer to ignore the cache and re-bundle ',
})
.strict()
.help(),
async({ entry, theme, port, open, log, remote }) => {
async({ entry, theme, port, open, log, remote, force }) => {
if (!fs.existsSync(entry) && !entry.endsWith('.md'))
entry = `${entry}.md`

Expand Down Expand Up @@ -101,6 +107,7 @@ cli.command(
port,
open,
host: remote ? '0.0.0.0' : 'localhost',
force,
},
logLevel: log as LogLevel,
},
Expand Down
8 changes: 5 additions & 3 deletions packages/slidev/node/plugins/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { ResolvedSlidevOptions } from '../options'
import { resolveImportPath, toAtFS } from '../utils'

const EXCLUDE = [
'@slidev/types',
'@slidev/shared',
'mermaid',
'@slidev/types',
'@vueuse/core',
'@vueuse/shared',
'mermaid',
'vite-plugin-windicss',
'vue-demi',
]

Expand All @@ -28,7 +29,6 @@ export function createConfigPlugin(options: ResolvedSlidevOptions): Plugin {
resolve: {
alias: {
'@slidev/client/': `${toAtFS(options.clientRoot)}/`,
'vue': `${resolveImportPath('vue/dist/vue.esm-browser.js', true)}`,
},
},
optimizeDeps: {
Expand All @@ -51,6 +51,8 @@ export function createConfigPlugin(options: ResolvedSlidevOptions): Plugin {
if (isInstalledGlobally) {
injection.cacheDir = join(options.cliRoot, 'node_modules/.vite')
injection.root = options.cliRoot
// @ts-expect-error
injection.resolve.alias.vue = `${resolveImportPath('vue/dist/vue.esm-browser.js', true)}`
}

return mergeConfig(config, injection)
Expand Down
2 changes: 1 addition & 1 deletion packages/slidev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"vite-plugin-icons": "^0.5.1",
"vite-plugin-md": "^0.6.7",
"vite-plugin-remote-assets": "^0.2.2",
"vite-plugin-windicss": "^0.16.2",
"vite-plugin-windicss": "^0.16.3",
"vue": "^3.0.11",
"windicss": "^3.0.12",
"yargs": "^17.0.1"
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3311833

Please sign in to comment.