Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Nov 3, 2023
1 parent 58f5f23 commit b7ad89c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(() => {
(function() {
// <define:import.meta.env>
var define_import_meta_env_default = { VITE_ENV_FROM_ENVFILE: "imfromdotenv", BASE_URL: "/temp/", MODE: "development", DEV: true, PROD: false };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(() => {
(function() {
// public-typescript/test.ts
var a = 1;
console.log(a);
Expand Down
4 changes: 1 addition & 3 deletions playground/temp-spa/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ export default defineConfig(() => ({
publicTypescript({
inputDir: 'public-typescript',
manifestName: 'manifest',
hash: true,
outputDir: 'out',
destination: 'file',
cacheDir: 'node_modules/.vite-plugin-public-typescript',
babel: false,
babel: true,
}),
injectScripts((manifest) => [
{
Expand Down
3 changes: 2 additions & 1 deletion src/node/helper/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const debug = createDebug('vite-plugin-public-typescript:util ===> ')

type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>

export type OptionsTypeWithDefault = PartialBy<Required<VPPTPluginOptions>, 'base' | 'sideEffects'>
export type OptionsTypeWithDefault = PartialBy<Required<VPPTPluginOptions>, 'base' | 'publicDir' | 'sideEffects'>

export { pkgName }

Expand Down Expand Up @@ -184,6 +184,7 @@ export async function setupGlobalConfig(viteConfig: ResolvedConfig, opts: Option
const resolvedRoot = normalizePath(viteConfig.root ? path.resolve(viteConfig.root) : process.cwd())

opts.base = opts.base ?? viteConfig.base
opts.publicDir = opts.publicDir ?? viteConfig.publicDir

fs.ensureDirSync(getInputDir(resolvedRoot, opts.inputDir))

Expand Down
15 changes: 10 additions & 5 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface VPPTPluginOptions {
inputDir?: string
/**
* @description output public javascript dir after build
* @note relative with vite.config.ts `publicDir`
* @note relative with `publicDir`
* @example
* ```ts
* // vite.config.ts
Expand All @@ -44,10 +44,15 @@ export interface VPPTPluginOptions {
* @default '/'
*/
outputDir?: string
/**
* @description public dir
* @default `publicDir` of vite config
* @version v2.2.0 introduced
*/
publicDir?: string
/**
* @description esbuild BuildOptions
* @see https://esbuild.github.io/api/#build-api
* @default {}
* @see https://esbuild.github.io/api/#general-options
*/
esbuildOptions?: BuildOptions | undefined
/**
Expand Down Expand Up @@ -84,7 +89,7 @@ export interface VPPTPluginOptions {
cacheDir?: string
/**
* @description base path for all files
* @default vite.config.ts `base`
* @default `base` of vite config
* @version v2.0.0 introduced
*/
base?: string
Expand Down Expand Up @@ -223,4 +228,4 @@ export default function publicTypescript(options: VPPTPluginOptions = {}) {
export { getManifest } from './manifest-cache'
export { type ScriptDescriptor, injectScripts, injectScriptsToHtml } from './plugins/inject-script'
export { publicTypescript }
export { DEFAULT_OPTIONS }
export { DEFAULT_OPTIONS as options }

0 comments on commit b7ad89c

Please sign in to comment.