diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index b9d3517..8840a29 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -1,18 +1,18 @@ :root { --light-hl-0: #A31515; --dark-hl-0: #CE9178; - --light-hl-1: #AF00DB; - --dark-hl-1: #C586C0; - --light-hl-2: #000000; - --dark-hl-2: #D4D4D4; - --light-hl-3: #001080; - --dark-hl-3: #9CDCFE; - --light-hl-4: #795E26; - --dark-hl-4: #DCDCAA; - --light-hl-5: #008000; - --dark-hl-5: #6A9955; - --light-hl-6: #0000FF; - --dark-hl-6: #569CD6; + --light-hl-1: #0000FF; + --dark-hl-1: #569CD6; + --light-hl-2: #AF00DB; + --dark-hl-2: #C586C0; + --light-hl-3: #000000; + --dark-hl-3: #D4D4D4; + --light-hl-4: #001080; + --dark-hl-4: #9CDCFE; + --light-hl-5: #795E26; + --dark-hl-5: #DCDCAA; + --light-hl-6: #008000; + --dark-hl-6: #6A9955; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } diff --git a/docs/assets/search.js b/docs/assets/search.js index 2fba562..cc625ad 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE71bSY/iyBL+L8nVRZMrULdZDu9dZqTR6F1QCVHg6rYabGSbXqZU//0p7bQdYTLwgpkTTVcsX+QXERl2Ju8sTb5n7Hnzzr5G8YE9i4DFu1PIntm3KA+fzsfL5yh+2ien1ygOP2XpngXskh7ZMzslh8sxzD5ZuW0pt3Vy2yzdz7/kpyML2P64y7IwY8+MfQS1l8V6yXXj6+90F2dvSXr6w36vPOQ/zzfsIx2Pt4Cdd2kY5zdCaQAZraWp4Wy31vVoHLNafxAcbAmulm6g/XnOoyTOamxRnIfp225/A6BTuXeJ+EKoGgZMhIEQZqXusKWpwibg5Lv0c5iPRlSrTwvKm9SDsbWsTAox/HFO0nx0Ns0a/UlhHe6AdJgezv77YTScUvdeOAasTfi2uxyb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UgjdPQcKDlRRdytE/4aG4pQT0gW/ZpY81Qc+QFWdU0ZUn5CBxNEgcaqXrH1CAlQZ6nEq48kq2pzVxA7SXLu0kYaU+NAeogb6iKt3plVccgC5YLkUtdHnTHgAG7IhqjQWh7O56IKeLHr2ivqAIuAWBSlIv25WnmMAfKARNFUD5Sq1R0gDkkkoge7CDPIkenccq7YpjzNZWo4BLfUu7oDH1pJICdacpOmsLWBVA11TuN6pt6KCraSoHy5uwgE9QNpJK+PJ9I/C0BPsaFaK9pvlaX9MEHoGypFbYs64QqCvQahRwjVW779r93VD1UL6YReXUmg4Ct/EGrnVWxRW4YglcagXMUBt0dbK0b624AhVkqAoC545AEywB6bb6lRuIDfQXTpWee0mN3Kk+7mwmXg9OErQnTdHQCg+2UMcBlZDuyg3wB5JKU1irX1I3alDLuaTA1geaIJNBrxDVLEJBBr9nA9QAAJwq+FqzTSycYpx3wkR9PxOABw2Z3DjsMQZUWkxcJi8BO0fn8BjFIXvevHx8/B9lrwsq80EAAA=="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE71by27byBL9l9aWVtRPSt7NY3HvZgYYDO5GMARZohMiMimQlJOMkX+/aLJJVlFd4kP0rGQl9ThVp7q6yG69syz9lrPH7Tv7GidH9igCluxfI/bI3uIiejifLp/j5OGQvj7HSfQpzw4sYJfsxB7Za3q8nKL8k5XbVXI7J7fLs8PyS/F6YgE7nPZ5HuXskbGfQeNltQm5bn39ne2T/CXNXv+w32sPxY/zDftIx+MtYOd9FiXFjVBaQEZraRo4u511PRnHotEfBQdbgtnSLbQ/z0WcJnmDLU6KKHvZH24AdCr3poivhGpgwEIYCWFR6Y5LTR02AafYZ5+jYjKiRn1WUOlblH3L4iKajAtamDdf3vU2Om0dK7NCjL6f06yYXOiLVn9eWMlLmh2m56zVnxXW4dtxMqRK9144pgVzjF72l1O7HF8uyaEUJ/E4jXtbFLF5nfv3rXP/lgWa8N/D2k1ltBIeEdr53sZ75Xd4yz1/alUpC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wkpzag5QA++aWr9Or7rjAHRBuhSV6OqqPQAMKkPUOZaEsrvsgZyuBnSA5oYi4BYEKkm9fF8dYwJ/AK+mFkD1Tq1V0gBkSBWQPdlBnsSAdmKV9uU5ZmcDUcClvqVd0ph5SkmBdacpOhsLWBVA11Ttt6pd6KCPGqoGq6uwgE+w3CRV8NULR+AJrBZDhWjvaT439zSBR6AsqQx78gqBugXqmrl037X7rl3TN9R6AD+vbe3DDZzQq97oomXYmRUCtw0HruXWizJwiyxwJRkwQ23X9ZHUocOUAivPUCsPHFgCTZA60m398zgQG1DjVErc223kTg1xZyv4eoySgAVN0dcJD+TFEc+pQnZ3dYA/UIyawlr/SrxVg1rOJQW2OQkFKwD0GFEPJhRk8EM4QA1IE6caRaPZJRYOjZV3ahk2FzsBeNDIyQ3nrbO2VjMvk6eAneNzdIqTiD1un37+/D8i5S3Dz0IAAA=="; \ No newline at end of file diff --git a/docs/functions/vite_plugin_combine_src.default.html b/docs/functions/vite_plugin_combine_src.default.html index 5bc0375..25b9afb 100644 --- a/docs/functions/vite_plugin_combine_src.default.html +++ b/docs/functions/vite_plugin_combine_src.default.html @@ -1 +1 @@ -default | vite-plugins

Generated using TypeDoc

\ No newline at end of file +default | vite-plugins

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/vite_plugin_cp_src.default.html b/docs/functions/vite_plugin_cp_src.default.html index 22f5bbd..50262ca 100644 --- a/docs/functions/vite_plugin_cp_src.default.html +++ b/docs/functions/vite_plugin_cp_src.default.html @@ -1,6 +1,6 @@ default | vite-plugins
  • Copy files and directories.

    Parameters

    Returns Plugin

    a vite plugin

    -

    Example

    import { defineConfig } from 'vite';
    import cp from 'vite-plugin-cp';

    export default defineConfig({
    plugins: [
    cp({
    targets: [
    // copy files of './node_modules/vite/dist' to 'dist/test'
    { src: './node_modules/vite/dist', dest: 'dist/test' },

    // copy files of './node_modules/vite/dist' to 'dist/test2'
    // and keep the directory structure of copied files
    { src: './node_modules/vite/dist', dest: 'dist/test2', flatten: false },

    // copy './node_modules/vite/README.md' to 'dist'
    { src: './node_modules/vite/README.md', dest: 'dist' },
    ]
    })
    ]
    }); +

    Example

    import { defineConfig } from 'vite';
    import cp from 'vite-plugin-cp';

    export default defineConfig({
    plugins: [
    cp({
    targets: [
    // copy files of './node_modules/vite/dist' to 'dist/test'
    { src: './node_modules/vite/dist', dest: 'dist/test' },

    // copy files of './node_modules/vite/dist' to 'dist/test2'
    // and keep the directory structure of copied files
    { src: './node_modules/vite/dist', dest: 'dist/test2', flatten: false },

    // copy './node_modules/vite/README.md' to 'dist'
    { src: './node_modules/vite/README.md', dest: 'dist' },
    ]
    })
    ]
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/vite_plugin_external_src.default.html b/docs/functions/vite_plugin_external_src.default.html index 11fd869..9b0e413 100644 --- a/docs/functions/vite_plugin_external_src.default.html +++ b/docs/functions/vite_plugin_external_src.default.html @@ -1,6 +1,6 @@ default | vite-plugins
  • provides a way of excluding dependencies from the runtime code and output bundles.

    Parameters

    Returns Plugin

    a vite plugin

    -

    Example

    import createExternal from 'vite-plugin-external';

    export default defineConfig({
    plugins: [
    createExternal({
    externals: {
    react: 'React'
    }
    })
    ],
    build: {
    cssCodeSplit: false,
    rollupOptions: {
    output: {
    manualChunks: undefined,
    assetFileNames: 'assets/[name][extname]',
    entryFileNames: '[name].js',
    format: 'iife'
    }
    }
    }
    }); +

    Example

    import createExternal from 'vite-plugin-external';

    export default defineConfig({
    plugins: [
    createExternal({
    externals: {
    react: 'React'
    }
    })
    ],
    build: {
    cssCodeSplit: false,
    rollupOptions: {
    output: {
    manualChunks: undefined,
    assetFileNames: 'assets/[name][extname]',
    entryFileNames: '[name].js',
    format: 'iife'
    }
    }
    }
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/vite_plugin_hook_use_src.default.html b/docs/functions/vite_plugin_hook_use_src.default.html index 1f240a8..ec0f37b 100644 --- a/docs/functions/vite_plugin_hook_use_src.default.html +++ b/docs/functions/vite_plugin_hook_use_src.default.html @@ -1,5 +1,5 @@ default | vite-plugins
  • Shows the usage of the hook function of the vite plugin.

    Returns Plugin

    a vite plugin

    -

    Example

    import { defineConfig } from 'vite';
    import vitePluginHookUse from 'vite-plugin-hook-use';

    export default defineConfig({
    plugins: [
    vitePluginHookUse()
    ]
    }); +

    Example

    import { defineConfig } from 'vite';
    import vitePluginHookUse from 'vite-plugin-hook-use';

    export default defineConfig({
    plugins: [
    vitePluginHookUse()
    ]
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/vite_plugin_include_css_src.default.html b/docs/functions/vite_plugin_include_css_src.default.html index d9f06a5..db11bf4 100644 --- a/docs/functions/vite_plugin_include_css_src.default.html +++ b/docs/functions/vite_plugin_include_css_src.default.html @@ -1,5 +1,5 @@ default | vite-plugins
  • build css into individual js files instead of using css links.

    Returns Plugin

    a vite plugin

    -

    Example

    import { defineConfig } from 'vite';
    import includeCSS from 'vite-plugin-include-css';

    export default defineConfig({
    plugins: [
    includeCSS()
    ],
    build: {
    cssCodeSplit: false,
    rollupOptions: {
    output: {
    manualChunks: undefined,
    assetFileNames: 'assets/[name][extname]',
    entryFileNames: '[name].js',
    format: 'iife'
    }
    }
    }
    }); +

    Example

    import { defineConfig } from 'vite';
    import includeCSS from 'vite-plugin-include-css';

    export default defineConfig({
    plugins: [
    includeCSS()
    ],
    build: {
    cssCodeSplit: false,
    rollupOptions: {
    output: {
    manualChunks: undefined,
    assetFileNames: 'assets/[name][extname]',
    entryFileNames: '[name].js',
    format: 'iife'
    }
    }
    }
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/vite_plugin_mock_data_src.default.html b/docs/functions/vite_plugin_mock_data_src.default.html index 7961aa4..d961932 100644 --- a/docs/functions/vite_plugin_mock_data_src.default.html +++ b/docs/functions/vite_plugin_mock_data_src.default.html @@ -1,6 +1,6 @@ default | vite-plugins
  • Provides a simple way to mock data.

    Parameters

    Returns Plugin

    a vite plugin

    -

    Example

    import { defineConfig } from 'vite';
    import mockData from 'vite-plugin-mock-data';

    export default defineConfig({
    plugins: [
    mockData({
    mockRoutesDir: './mock'
    })
    ]
    }); +

    Example

    import { defineConfig } from 'vite';
    import mockData from 'vite-plugin-mock-data';

    export default defineConfig({
    plugins: [
    mockData({
    mockRoutesDir: './mock'
    })
    ]
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/vite_plugin_reverse_proxy_src.default.html b/docs/functions/vite_plugin_reverse_proxy_src.default.html index 97f549c..f10c664 100644 --- a/docs/functions/vite_plugin_reverse_proxy_src.default.html +++ b/docs/functions/vite_plugin_reverse_proxy_src.default.html @@ -1,6 +1,6 @@ default | vite-plugins
  • Makes the script to be served with the text/javascript MIME type instead of module MIME type.

    Parameters

    Returns {
        name: string;
        config(config): void;
        configResolved(config): void;
        load(id): undefined | string;
    }

    a vite plugin

    -

    Example

    import { defineConfig } from 'vite';
    import reverseProxy from 'vite-plugin-reverse-proxy';

    export default defineConfig({
    plugins: [
    reverseProxy({
    targets: {
    '/app.js':'src/main.jsx'
    }
    }),
    ]
    }); +

    Example

    import { defineConfig } from 'vite';
    import reverseProxy from 'vite-plugin-reverse-proxy';

    export default defineConfig({
    plugins: [
    reverseProxy({
    targets: {
    '/app.js':'src/main.jsx'
    }
    }),
    ]
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_combine_src.Options.html b/docs/interfaces/vite_plugin_combine_src.Options.html index 77d7f01..38e2845 100644 --- a/docs/interfaces/vite_plugin_combine_src.Options.html +++ b/docs/interfaces/vite_plugin_combine_src.Options.html @@ -1,22 +1,28 @@ -Options | vite-plugins
interface Options {
    cwd?: string;
    dts?: string;
    exports?: "named" | "default" | "none";
    src: string | string[];
    target: string;
    transformName?: boolean | TransformName;
}

Properties

cwd? -dts? +Options | vite-plugins
interface Options {
    cwd?: string;
    enforce?: "pre" | "post";
    exports?: "named" | "default" | "none";
    overwrite?: boolean;
    src: string | string[];
    target: string;
    transformName?: boolean | TransformName;
}

Properties

cwd?: string

Current Working Directory.

当前工作目录

-
dts?: string

Generate the index.d.ts file to a specified path.

-

生成 index.d.ts 文件到指定路径

-
exports?: "named" | "default" | "none"

Exported module types.

+
enforce?: "pre" | "post"

The value of enforce can be either "pre" or "post", see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering.

+

强制执行顺序,pre 前,post 后,参考 https://cn.vitejs.dev/guide/api-plugin.html#plugin-ordering。

+
exports?: "named" | "default" | "none"

Exported module types.

导出的模块类型

Default

'named'
 
-
src: string | string[]

Files prepared for merging.

+
overwrite?: boolean

Whether to overwrite the target file.

+

是否覆盖目标文件

+

Default

false
+
+
src: string | string[]

Files prepared for combine.

准备合并的文件

-
target: string

Merging into the target file.

+
target: string

Combines into the target file.

+

组合到目标文件

Default

'index.js'
 
-
transformName?: boolean | TransformName

Transform file names

+
transformName?: boolean | TransformName

Transforms file names.

转换文件名

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_cp_src.Options.html b/docs/interfaces/vite_plugin_cp_src.Options.html index 85527f3..8a5ce99 100644 --- a/docs/interfaces/vite_plugin_cp_src.Options.html +++ b/docs/interfaces/vite_plugin_cp_src.Options.html @@ -1,4 +1,4 @@ -Options | vite-plugins
interface Options {
    cwd?: string;
    enforce?: "pre" | "post";
    globbyOptions?: Options;
    hook?: string;
    targets: Target[];
}

Properties

cwd? +Options | vite-plugins
interface Options {
    cwd?: string;
    enforce?: "pre" | "post";
    globbyOptions?: Options;
    hook?: string;
    targets: Target[];
}

Properties

cwd? enforce? globbyOptions? hook? @@ -6,14 +6,14 @@

Properties

cwd?: string

Default process.cwd(), The current working directory in which to search.

默认 process.cwd(),用于拼接 src 的路径。

Default

process.cwd()

-
enforce?: "pre" | "post"

The value of enforce can be either "pre" or "post", see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering.

+
enforce?: "pre" | "post"

The value of enforce can be either "pre" or "post", see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering.

强制执行顺序,pre 前,post 后,参考 https://cn.vitejs.dev/guide/api-plugin.html#plugin-ordering

-
globbyOptions?: Options

Options for globby. See more at https://github.com/sindresorhus/globby#options

+
globbyOptions?: Options

Options for globby. See more at https://github.com/sindresorhus/globby#options

globby 的选项,设置 src 的匹配参数。

-
hook?: string

Default 'closeBundle', vite hook the plugin should use.

+
hook?: string

Default 'closeBundle', vite hook the plugin should use.

默认 'closeBundle',调用指定钩子函数时开始复制。

Default

'closeBundle'
 
-
targets: Target[]

Array of targets to copy.

+
targets: Target[]

Array of targets to copy.

复制文件的规则配置。

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_cp_src.Target.html b/docs/interfaces/vite_plugin_cp_src.Target.html index 498c024..3d24ed8 100644 --- a/docs/interfaces/vite_plugin_cp_src.Target.html +++ b/docs/interfaces/vite_plugin_cp_src.Target.html @@ -1,4 +1,4 @@ -Target | vite-plugins
interface Target {
    dest: string;
    flatten?: boolean;
    globbyOptions?: Options;
    rename?: string | ((name) => string);
    src: string | string[];
    transform?: ((buf, matchedPath) => string | Buffer | Promise<string | Buffer>);
}

Properties

dest +Target | vite-plugins
interface Target {
    dest: string;
    flatten?: boolean;
    globbyOptions?: Options;
    rename?: string | ((name) => string);
    src: string | string[];
    transform?: ((buf, matchedPath) => string | Buffer | Promise<string | Buffer>);
}

Properties

Properties

dest: string

One or more destinations where to copy.

复制到目标目录。

-
flatten?: boolean

Remove the directory structure of copied files, if src is a directory.

+
flatten?: boolean

Remove the directory structure of copied files, if src is a directory.

是否删除复制的文件目录结构,src 为目录时有效。

-
globbyOptions?: Options

Options for globby. See more at https://github.com/sindresorhus/globby#options

+
globbyOptions?: Options

Options for globby. See more at https://github.com/sindresorhus/globby#options

globby 的选项,设置 src 的匹配参数

-
rename?: string | ((name) => string)

Rename the file after copying.

+
rename?: string | ((name) => string)

Rename the file after copying.

复制后重命名文件。

-

Type declaration

    • (name): string
    • Parameters

      • name: string

      Returns string

src: string | string[]

Path or glob of what to copy.

+

Type declaration

    • (name): string
    • Parameters

      • name: string

      Returns string

src: string | string[]

Path or glob of what to copy.

要复制的目录、文件或者 globby 匹配规则。

-
transform?: ((buf, matchedPath) => string | Buffer | Promise<string | Buffer>)

Transform the file before copying.

+
transform?: ((buf, matchedPath) => string | Buffer | Promise<string | Buffer>)

Transform the file before copying.

复制前转换文件内容。

-

Type declaration

    • (buf, matchedPath): string | Buffer | Promise<string | Buffer>
    • Parameters

      • buf: Buffer
      • matchedPath: string

      Returns string | Buffer | Promise<string | Buffer>

Generated using TypeDoc

\ No newline at end of file +

Type declaration

    • (buf, matchedPath): string | Buffer | Promise<string | Buffer>
    • Parameters

      • buf: Buffer
      • matchedPath: string

      Returns string | Buffer | Promise<string | Buffer>

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_external_src.BasicOptions.html b/docs/interfaces/vite_plugin_external_src.BasicOptions.html index 75364e8..88e3aa4 100644 --- a/docs/interfaces/vite_plugin_external_src.BasicOptions.html +++ b/docs/interfaces/vite_plugin_external_src.BasicOptions.html @@ -1,12 +1,12 @@ -BasicOptions | vite-plugins
interface BasicOptions {
    cacheDir?: string;
    cwd?: string;
    externals?: Record<string, any>;
}

Hierarchy (view full)

Properties

cacheDir? +BasicOptions | vite-plugins
interface BasicOptions {
    cacheDir?: string;
    cwd?: string;
    externals?: Record<string, any>;
}

Hierarchy (view full)

Properties

cacheDir?: string

Cache folder

缓存文件夹

Default

${cwd}/node_modules/.vite_external

-
cwd?: string

The current working directory in which to join cacheDir.

+
cwd?: string

The current working directory in which to join cacheDir.

用于拼接 cacheDir 的路径。

Default

process.cwd()

-
externals?: Record<string, any>

External dependencies

+
externals?: Record<string, any>

External dependencies

配置外部依赖

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_external_src.Options.html b/docs/interfaces/vite_plugin_external_src.Options.html index d4745ad..7adddcb 100644 --- a/docs/interfaces/vite_plugin_external_src.Options.html +++ b/docs/interfaces/vite_plugin_external_src.Options.html @@ -1,6 +1,6 @@ Options | vite-plugins
interface Options {
    cacheDir?: string;
    cwd?: string;
    enforce?: "pre" | "post";
    externalizeDeps?: (string | RegExp)[];
    externals?: Record<string, any>;
    interop?: "auto";
    mode?: string;
    nodeBuiltins?: boolean;
    [mode: string]: BasicOptions | any;
}

Hierarchy (view full)

Indexable

[mode: string]: BasicOptions | any

External dependencies for specific mode

针对指定的模式配置外部依赖

-

Properties

Properties

Properties

cacheDir?: string

Cache folder

缓存文件夹

Default

${cwd}/node_modules/.vite_external

-
cwd?: string

The current working directory in which to join cacheDir.

+
cwd?: string

The current working directory in which to join cacheDir.

用于拼接 cacheDir 的路径。

Default

process.cwd()

-
enforce?: "pre" | "post"

The value of enforce can be either "pre" or "post", see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering.

+
enforce?: "pre" | "post"

The value of enforce can be either "pre" or "post", see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering.

强制执行顺序,pre 前,post 后,参考 https://cn.vitejs.dev/guide/api-plugin.html#plugin-ordering。

-
externalizeDeps?: (string | RegExp)[]

Specify dependencies to not be included in the bundle

+
externalizeDeps?: (string | RegExp)[]

Specify dependencies to not be included in the bundle

排除不需要打包的依赖。

-
externals?: Record<string, any>

External dependencies

+
externals?: Record<string, any>

External dependencies

配置外部依赖

-
interop?: "auto"

Controls how Rollup handles default.

+
interop?: "auto"

Controls how Rollup handles default.

用于控制读取外部依赖的默认值。

-
mode?: string

Different externals can be specified in different modes.

+
mode?: string

Different externals can be specified in different modes.

在不同的模式下,可以指定不同的外部依赖。

-
nodeBuiltins?: boolean

Whether to exclude nodejs built-in modules in the bundle

+
nodeBuiltins?: boolean

Whether to exclude nodejs built-in modules in the bundle

是否排除 nodejs 内置模块。

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_mock_data_src.HandleRoute.html b/docs/interfaces/vite_plugin_mock_data_src.HandleRoute.html index b8c3842..e764a1e 100644 --- a/docs/interfaces/vite_plugin_mock_data_src.HandleRoute.html +++ b/docs/interfaces/vite_plugin_mock_data_src.HandleRoute.html @@ -1,5 +1,5 @@ -HandleRoute | vite-plugins
interface HandleRoute {
    file?: string;
    handler?: any;
    options?: RouteOptions;
    store?: any;
}

Properties

file? +HandleRoute | vite-plugins
interface HandleRoute {
    file?: string;
    handler?: any;
    options?: RouteOptions;
    store?: any;
}

Properties

file?: string
handler?: any
options?: RouteOptions
store?: any

Generated using TypeDoc

\ No newline at end of file +

Properties

file?: string
handler?: any
options?: RouteOptions
store?: any

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_mock_data_src.Options.html b/docs/interfaces/vite_plugin_mock_data_src.Options.html index cc75e62..56c9984 100644 --- a/docs/interfaces/vite_plugin_mock_data_src.Options.html +++ b/docs/interfaces/vite_plugin_mock_data_src.Options.html @@ -1,4 +1,4 @@ -Options | vite-plugins
interface Options {
    cwd?: string;
    isAfter?: boolean;
    mockAssetsDir?: string;
    mockRouterOptions?: Config<V1> | Config<V2>;
    mockRoutes?: RouteConfig | RouteConfig[];
    mockRoutesDir?: string;
}

Properties

cwd? +Options | vite-plugins
interface Options {
    cwd?: string;
    isAfter?: boolean;
    mockAssetsDir?: string;
    mockRouterOptions?: Config<V1> | Config<V2>;
    mockRoutes?: RouteConfig | RouteConfig[];
    mockRoutesDir?: string;
}

Properties

cwd?: string

The directory to serve files from.

Default

process.cwd()

-
isAfter?: boolean

If true, these mock routes is matched after internal middlewares are installed.

+
isAfter?: boolean

If true, these mock routes is matched after internal middlewares are installed.

Default

false

-
mockAssetsDir?: string

Specify the directory to define mock assets.

-
mockRouterOptions?: Config<V1> | Config<V2>

Initial options of find-my-way. see more at https://github.com/delvedor/find-my-way#findmywayoptions

-
mockRoutes?: RouteConfig | RouteConfig[]

Initial list of mock routes that should be added to the dev server.

-
mockRoutesDir?: string

Specify the directory to define mock routes that should be added to the dev server.

-

Generated using TypeDoc

\ No newline at end of file +
mockAssetsDir?: string

Specify the directory to define mock assets.

+
mockRouterOptions?: Config<V1> | Config<V2>

Initial options of find-my-way. see more at https://github.com/delvedor/find-my-way#findmywayoptions

+
mockRoutes?: RouteConfig | RouteConfig[]

Initial list of mock routes that should be added to the dev server.

+
mockRoutesDir?: string

Specify the directory to define mock routes that should be added to the dev server.

+

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_mock_data_src.RouteConfig.html b/docs/interfaces/vite_plugin_mock_data_src.RouteConfig.html index 6866005..4c55c95 100644 --- a/docs/interfaces/vite_plugin_mock_data_src.RouteConfig.html +++ b/docs/interfaces/vite_plugin_mock_data_src.RouteConfig.html @@ -1 +1 @@ -RouteConfig | vite-plugins
interface RouteConfig {
    [route: string]: string | Handler<HTTPVersion.V1> | HandleRoute;
}

Indexable

[route: string]: string | Handler<HTTPVersion.V1> | HandleRoute

Generated using TypeDoc

\ No newline at end of file +RouteConfig | vite-plugins
interface RouteConfig {
    [route: string]: string | Handler<HTTPVersion.V1> | HandleRoute;
}

Indexable

[route: string]: string | Handler<HTTPVersion.V1> | HandleRoute

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/vite_plugin_reverse_proxy_src.Options.html b/docs/interfaces/vite_plugin_reverse_proxy_src.Options.html index d02105a..ce71723 100644 --- a/docs/interfaces/vite_plugin_reverse_proxy_src.Options.html +++ b/docs/interfaces/vite_plugin_reverse_proxy_src.Options.html @@ -1,5 +1,5 @@ -Options | vite-plugins
interface Options {
    preambleCode?: string;
    targets: Record<string, string>;
}

Properties

preambleCode? +Options | vite-plugins
interface Options {
    preambleCode?: string;
    targets: Record<string, string>;
}

Properties

preambleCode?: string

The preamble code to be injected before the main script.

-
targets: Record<string, string>

The target script to be proxied.

-

Generated using TypeDoc

\ No newline at end of file +
targets: Record<string, string>

The target script to be proxied.

+

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/vite_plugin_combine_src.html b/docs/modules/vite_plugin_combine_src.html index 5f05ebe..2cc5296 100644 --- a/docs/modules/vite_plugin_combine_src.html +++ b/docs/modules/vite_plugin_combine_src.html @@ -1,4 +1,4 @@ -vite-plugin-combine/src | vite-plugins

Module vite-plugin-combine/src

Index

Interfaces

Options +vite-plugin-combine/src | vite-plugins

Module vite-plugin-combine/src

Index

Interfaces

Type Aliases

Functions

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/vite_plugin_cp_src.html b/docs/modules/vite_plugin_cp_src.html index 24d64e1..bb4d68f 100644 --- a/docs/modules/vite_plugin_cp_src.html +++ b/docs/modules/vite_plugin_cp_src.html @@ -1,4 +1,4 @@ -vite-plugin-cp/src | vite-plugins

Module vite-plugin-cp/src

Index

Interfaces

Options +vite-plugin-cp/src | vite-plugins

Module vite-plugin-cp/src

Index

Interfaces

Functions

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/vite_plugin_external_src.html b/docs/modules/vite_plugin_external_src.html index 9c4de02..91d7bc4 100644 --- a/docs/modules/vite_plugin_external_src.html +++ b/docs/modules/vite_plugin_external_src.html @@ -1,4 +1,4 @@ -vite-plugin-external/src | vite-plugins

Module vite-plugin-external/src

Index

Interfaces

BasicOptions +vite-plugin-external/src | vite-plugins

Module vite-plugin-external/src

Index

Interfaces

Functions

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/vite_plugin_hook_use_src.html b/docs/modules/vite_plugin_hook_use_src.html index 0fea0a8..f00e3d3 100644 --- a/docs/modules/vite_plugin_hook_use_src.html +++ b/docs/modules/vite_plugin_hook_use_src.html @@ -1,2 +1,2 @@ -vite-plugin-hook-use/src | vite-plugins

Module vite-plugin-hook-use/src

Index

Functions

default +vite-plugin-hook-use/src | vite-plugins

Module vite-plugin-hook-use/src

Index

Functions

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/vite_plugin_include_css_src.html b/docs/modules/vite_plugin_include_css_src.html index 89fae79..cade672 100644 --- a/docs/modules/vite_plugin_include_css_src.html +++ b/docs/modules/vite_plugin_include_css_src.html @@ -1,2 +1,2 @@ -vite-plugin-include-css/src | vite-plugins

Module vite-plugin-include-css/src

Index

Functions

default +vite-plugin-include-css/src | vite-plugins

Module vite-plugin-include-css/src

Index

Functions

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/vite_plugin_mock_data_src.html b/docs/modules/vite_plugin_mock_data_src.html index 30b5215..2a6c363 100644 --- a/docs/modules/vite_plugin_mock_data_src.html +++ b/docs/modules/vite_plugin_mock_data_src.html @@ -1,4 +1,4 @@ -vite-plugin-mock-data/src | vite-plugins

Module vite-plugin-mock-data/src

Index

Interfaces

HandleRoute +vite-plugin-mock-data/src | vite-plugins

Module vite-plugin-mock-data/src

Index

Interfaces

Functions

default diff --git a/docs/modules/vite_plugin_reverse_proxy_src.html b/docs/modules/vite_plugin_reverse_proxy_src.html index c0cb6c9..d475507 100644 --- a/docs/modules/vite_plugin_reverse_proxy_src.html +++ b/docs/modules/vite_plugin_reverse_proxy_src.html @@ -1,3 +1,3 @@ -vite-plugin-reverse-proxy/src | vite-plugins

Module vite-plugin-reverse-proxy/src

Index

Interfaces

Options +vite-plugin-reverse-proxy/src | vite-plugins

Module vite-plugin-reverse-proxy/src

Index

Interfaces

Functions

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/types/vite_plugin_combine_src.TransformName.html b/docs/types/vite_plugin_combine_src.TransformName.html index 430782e..7a19262 100644 --- a/docs/types/vite_plugin_combine_src.TransformName.html +++ b/docs/types/vite_plugin_combine_src.TransformName.html @@ -1 +1 @@ -TransformName | vite-plugins
TransformName: ((name, filePath) => string)

Type declaration

    • (name, filePath): string
    • Parameters

      • name: string
      • filePath: string

      Returns string

Generated using TypeDoc

\ No newline at end of file +TransformName | vite-plugins
TransformName: ((name, filePath) => string)

Type declaration

    • (name, filePath): string
    • Parameters

      • name: string
      • filePath: string

      Returns string

Generated using TypeDoc

\ No newline at end of file diff --git a/examples/vite3-combine/src/index.js b/examples/vite3-combine/src/index.js new file mode 100644 index 0000000..41dca8a --- /dev/null +++ b/examples/vite3-combine/src/index.js @@ -0,0 +1,4 @@ +export { default as isDate } from './isDate'; +export { default as isNil } from './isNil'; +export { default as isNumber } from './isNumber'; +export { default as isObject } from './isObject'; diff --git a/examples/vite3-combine/vite.config.js b/examples/vite3-combine/vite.config.js index 4eb474b..a945bb5 100644 --- a/examples/vite3-combine/vite.config.js +++ b/examples/vite3-combine/vite.config.js @@ -5,8 +5,9 @@ import vitePluginCombine from 'vite-plugin-combine'; export default defineConfig({ plugins: [ vitePluginCombine({ - src: 'src/*.js', - target: 'src/index.js' + src: ['src/*.js', '!src/index.js'], + target: 'src/index.js', + overwrite: true }) ], build: { diff --git a/examples/vite4-combine/vite.config.mjs b/examples/vite4-combine/vite.config.mjs index 2bd79c7..8aeb0ef 100644 --- a/examples/vite4-combine/vite.config.mjs +++ b/examples/vite4-combine/vite.config.mjs @@ -5,12 +5,11 @@ import vitePluginCombine from 'vite-plugin-combine'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ - ts(), vitePluginCombine({ src: 'src/*.ts', - target: 'src/index.ts', - dts: true - }) + target: 'src/index.ts' + }), + ts() ], build: { minify: false, diff --git a/examples/vite5-combine/vite.config.mjs b/examples/vite5-combine/vite.config.mjs index a42c904..c5083b6 100644 --- a/examples/vite5-combine/vite.config.mjs +++ b/examples/vite5-combine/vite.config.mjs @@ -5,13 +5,12 @@ import vitePluginCombine from 'vite-plugin-combine'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ - ts(), vitePluginCombine({ src: ['src/*.ts', '!src/noop.ts'], target: 'src/index.ts', - exports: 'default', - dts: true - }) + exports: 'default' + }), + ts() ], build: { minify: false, diff --git a/packages/vite-plugin-combine/README.md b/packages/vite-plugin-combine/README.md index 40d65e7..439709f 100644 --- a/packages/vite-plugin-combine/README.md +++ b/packages/vite-plugin-combine/README.md @@ -19,25 +19,35 @@ npm install vite-plugin-combine --save-dev ```ts export interface Options { /** - * Files prepared for combining. + * Files prepared for combine. * * 准备合并的文件 */ src: string | string[]; /** - * Merging into the target file. + * Combines into the target file. + * + * 组合到目标文件 * * @default 'index.js' */ target: string; /** - * Configuration for the camelcase function. - * https://github.com/sindresorhus/camelcase?tab=readme-ov-file#camelcaseinput-options + * Whether to overwrite the target file. + * + * 是否覆盖目标文件 + * + * @default false + */ + overwrite?: boolean; + + /** + * Transforms file names. * - * camelcase 函数的配置 + * 转换文件名 */ - camelCase?: CamelCaseOptions; + transformName?: TransformName | boolean; /** * Exported module types. @@ -49,13 +59,11 @@ export interface Options { exports?: 'named' | 'default' | 'none'; /** - * Whether to generate `.d.ts` files. - * - * 是否生成 d.ts 文件 + * The value of enforce can be either `"pre"` or `"post"`, see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering. * - * @default false + * 强制执行顺序,`pre` 前,`post` 后,参考 https://cn.vitejs.dev/guide/api-plugin.html#plugin-ordering。 */ - dts?: boolean; + enforce?: 'pre' | 'post'; /** * Current Working Directory. @@ -73,16 +81,23 @@ export interface Options { Files prepared for merging. **`target`** -* Type: `'index.js'` -* Required: string +* Type: `string` +* Required: true +* Default: `'index.js'` Merging into the target file. -**`camelCase`** -* Type: `CamelCase` +**`overwrite`** +* Type: `boolean` +* Required: false + +Whether to overwrite the target file. + +**`transformName`** +* Type: `TransformName | boolean` * Required: false -Configuration for the camelcase function. https://github.com/sindresorhus/camelcase?tab=readme-ov-file#camelcaseinput-options +Transform file names. **`exports`** * Type: `'named' | 'default' | 'none'` @@ -97,12 +112,6 @@ Exported module types. Current Working Directory. -**`dts`** -* Type: `boolean` -* Required: false - -Whether to generate `.d.ts` files. - ## Usage ```dir @@ -122,12 +131,11 @@ import vitePluginCombine from 'vite-plugin-combine'; export default defineConfig({ plugins: [ - ts(), vitePluginCombine({ src: 'src/*.ts', - target: 'src/index.ts', - dts: true - }) + target: 'src/index.ts' + }), + ts() ], build: { minify: false, diff --git a/packages/vite-plugin-combine/dist/index.d.ts b/packages/vite-plugin-combine/dist/index.d.ts index f843a14..8926822 100644 --- a/packages/vite-plugin-combine/dist/index.d.ts +++ b/packages/vite-plugin-combine/dist/index.d.ts @@ -2,19 +2,29 @@ import { Plugin } from 'vite'; export type TransformName = (name: string, filePath: string) => string; export interface Options { /** - * Files prepared for merging. + * Files prepared for combine. * * 准备合并的文件 */ src: string | string[]; /** - * Merging into the target file. + * Combines into the target file. + * + * 组合到目标文件 * * @default 'index.js' */ target: string; /** - * Transform file names + * Whether to overwrite the target file. + * + * 是否覆盖目标文件 + * + * @default false + */ + overwrite?: boolean; + /** + * Transforms file names. * * 转换文件名 */ @@ -28,11 +38,11 @@ export interface Options { */ exports?: 'named' | 'default' | 'none'; /** - * Generate the `index.d.ts` file to a specified path. + * The value of enforce can be either `"pre"` or `"post"`, see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering. * - * 生成 `index.d.ts` 文件到指定路径 + * 强制执行顺序,`pre` 前,`post` 后,参考 https://cn.vitejs.dev/guide/api-plugin.html#plugin-ordering。 */ - dts?: string; + enforce?: 'pre' | 'post'; /** * Current Working Directory. * diff --git a/packages/vite-plugin-combine/dist/index.js b/packages/vite-plugin-combine/dist/index.js index 71c2240..176013f 100644 --- a/packages/vite-plugin-combine/dist/index.js +++ b/packages/vite-plugin-combine/dist/index.js @@ -21,7 +21,7 @@ function namedExport(files, target, transformName) { const exportName = camelCaseName(name, file, transformName); const relativeDir = node_path.relative(node_path.dirname(target), dir); return `export { default as ${exportName} } from '${`./${node_path.join(relativeDir, name)}`}';`; - }).join(node_os.EOL); + }).join(node_os.EOL).concat(node_os.EOL); } function defaultExport(files, target, transformName) { const importDeclare = []; @@ -47,19 +47,39 @@ function createPlugin(opts) { if (!opts) { opts = {}; } - const { src, transformName, dts } = opts; + const { src, transformName, overwrite } = opts; + const enforce = opts.enforce || "pre"; const exportsType = opts.exports || "named"; - let target = opts.target || "index.js"; + const target = opts.target || "index.js"; const cwd = opts.cwd || process.cwd(); - if (!node_path.isAbsolute(target)) { - target = node_path.join(cwd, target); + let absTarget = target; + if (!node_path.isAbsolute(absTarget)) { + absTarget = node_path.join(cwd, absTarget); } - target = node_path.normalize(target); - const files = globby.globbySync(src, { cwd, absolute: true }); - let mainCode = ""; - return { + absTarget = node_path.normalize(absTarget); + if (!overwrite && node_fs.existsSync(absTarget)) { + throw new Error(`'${absTarget}' exists.`); + } + const plugin = { name: "vite-plugin-combine", - config(config) { + enforce + }; + const files = globby.globbySync(src, { cwd, absolute: true }); + if (files.length) { + let mainCode = ""; + switch (exportsType) { + case "named": + mainCode = namedExport(files, absTarget, transformName); + break; + case "default": { + mainCode = defaultExport(files, absTarget, transformName); + break; + } + default: + mainCode = noneExport(files, absTarget); + } + node_fs.writeFileSync(absTarget, mainCode, "utf-8"); + plugin.config = function(config) { var _a; const { build } = config; if (!build || !(build.lib && build.lib.entry) && !((_a = build.rollupOptions) == null ? void 0 : _a.input)) { @@ -71,46 +91,21 @@ function createPlugin(opts) { } }; } - }, - resolveId(id) { - if (id === target) { - return target; - } - }, - load(id) { - if (id === target) { - if (!files.length) { - return ""; - } - switch (exportsType) { - case "named": - mainCode = namedExport(files, id, transformName); - break; - case "default": { - mainCode = defaultExport(files, id, transformName); - break; - } - default: - mainCode = noneExport(files, id); - } - return mainCode; + }; + plugin.resolveId = function(id) { + if (id === target || id === absTarget) { + return absTarget; } - }, - closeBundle() { - if (dts) { - let dtsPath = dts; - if (!node_path.isAbsolute(dtsPath)) { - dtsPath = node_path.join(cwd, dtsPath); - } - if (mainCode) { - node_fs.writeFile(node_path.join(dtsPath, "index.d.ts"), mainCode, (err) => { - if (err) { - console.error(err); - } - }); + }; + if (!overwrite) { + plugin.closeBundle = function() { + try { + node_fs.unlinkSync(absTarget); + } catch (e) { } - } + }; } - }; + } + return plugin; } module.exports = createPlugin; diff --git a/packages/vite-plugin-combine/dist/index.mjs b/packages/vite-plugin-combine/dist/index.mjs index 1ffe25c..0789d15 100644 --- a/packages/vite-plugin-combine/dist/index.mjs +++ b/packages/vite-plugin-combine/dist/index.mjs @@ -1,6 +1,6 @@ import { EOL } from "node:os"; import { isAbsolute, join, normalize, parse, relative, dirname } from "node:path"; -import { writeFile } from "node:fs"; +import { existsSync, writeFileSync, unlinkSync } from "node:fs"; import camelCase from "camelcase"; import { globbySync } from "globby"; function camelCaseName(name, filePath, transformName) { @@ -20,7 +20,7 @@ function namedExport(files, target, transformName) { const exportName = camelCaseName(name, file, transformName); const relativeDir = relative(dirname(target), dir); return `export { default as ${exportName} } from '${`./${join(relativeDir, name)}`}';`; - }).join(EOL); + }).join(EOL).concat(EOL); } function defaultExport(files, target, transformName) { const importDeclare = []; @@ -46,19 +46,39 @@ function createPlugin(opts) { if (!opts) { opts = {}; } - const { src, transformName, dts } = opts; + const { src, transformName, overwrite } = opts; + const enforce = opts.enforce || "pre"; const exportsType = opts.exports || "named"; - let target = opts.target || "index.js"; + const target = opts.target || "index.js"; const cwd = opts.cwd || process.cwd(); - if (!isAbsolute(target)) { - target = join(cwd, target); + let absTarget = target; + if (!isAbsolute(absTarget)) { + absTarget = join(cwd, absTarget); } - target = normalize(target); - const files = globbySync(src, { cwd, absolute: true }); - let mainCode = ""; - return { + absTarget = normalize(absTarget); + if (!overwrite && existsSync(absTarget)) { + throw new Error(`'${absTarget}' exists.`); + } + const plugin = { name: "vite-plugin-combine", - config(config) { + enforce + }; + const files = globbySync(src, { cwd, absolute: true }); + if (files.length) { + let mainCode = ""; + switch (exportsType) { + case "named": + mainCode = namedExport(files, absTarget, transformName); + break; + case "default": { + mainCode = defaultExport(files, absTarget, transformName); + break; + } + default: + mainCode = noneExport(files, absTarget); + } + writeFileSync(absTarget, mainCode, "utf-8"); + plugin.config = function(config) { var _a; const { build } = config; if (!build || !(build.lib && build.lib.entry) && !((_a = build.rollupOptions) == null ? void 0 : _a.input)) { @@ -70,47 +90,22 @@ function createPlugin(opts) { } }; } - }, - resolveId(id) { - if (id === target) { - return target; - } - }, - load(id) { - if (id === target) { - if (!files.length) { - return ""; - } - switch (exportsType) { - case "named": - mainCode = namedExport(files, id, transformName); - break; - case "default": { - mainCode = defaultExport(files, id, transformName); - break; - } - default: - mainCode = noneExport(files, id); - } - return mainCode; + }; + plugin.resolveId = function(id) { + if (id === target || id === absTarget) { + return absTarget; } - }, - closeBundle() { - if (dts) { - let dtsPath = dts; - if (!isAbsolute(dtsPath)) { - dtsPath = join(cwd, dtsPath); - } - if (mainCode) { - writeFile(join(dtsPath, "index.d.ts"), mainCode, (err) => { - if (err) { - console.error(err); - } - }); + }; + if (!overwrite) { + plugin.closeBundle = function() { + try { + unlinkSync(absTarget); + } catch (e) { } - } + }; } - }; + } + return plugin; } export { createPlugin as default diff --git a/packages/vite-plugin-combine/package.json b/packages/vite-plugin-combine/package.json index 19a98a6..13978f3 100644 --- a/packages/vite-plugin-combine/package.json +++ b/packages/vite-plugin-combine/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-combine", - "version": "4.0.1", + "version": "4.0.2", "description": "Combines specified files to produce a single master file.", "types": "./dist/index.d.ts", "module": "./dist/index.mjs", diff --git a/packages/vite-plugin-combine/src/index.ts b/packages/vite-plugin-combine/src/index.ts index a173c51..4f153cd 100644 --- a/packages/vite-plugin-combine/src/index.ts +++ b/packages/vite-plugin-combine/src/index.ts @@ -1,6 +1,6 @@ import { EOL } from 'node:os'; import { parse, isAbsolute, join, normalize, relative, dirname } from 'node:path'; -import { writeFile } from 'node:fs'; +import { writeFileSync, existsSync, unlinkSync } from 'node:fs'; import camelCase from 'camelcase'; import { globbySync } from 'globby'; @@ -10,20 +10,31 @@ export type TransformName = (name: string, filePath: string) => string; export interface Options { /** - * Files prepared for merging. + * Files prepared for combine. * * 准备合并的文件 */ src: string | string[]; /** - * Merging into the target file. + * Combines into the target file. + * + * 组合到目标文件 * * @default 'index.js' */ target: string; /** - * Transform file names + * Whether to overwrite the target file. + * + * 是否覆盖目标文件 + * + * @default false + */ + overwrite?: boolean; + + /** + * Transforms file names. * * 转换文件名 */ @@ -39,11 +50,11 @@ export interface Options { exports?: 'named' | 'default' | 'none'; /** - * Generate the `index.d.ts` file to a specified path. + * The value of enforce can be either `"pre"` or `"post"`, see more at https://vitejs.dev/guide/api-plugin.html#plugin-ordering. * - * 生成 `index.d.ts` 文件到指定路径 + * 强制执行顺序,`pre` 前,`post` 后,参考 https://cn.vitejs.dev/guide/api-plugin.html#plugin-ordering。 */ - dts?: string; + enforce?: 'pre' | 'post'; /** * Current Working Directory. @@ -73,7 +84,8 @@ function namedExport(files: string[], target: string, transformName?: TransformN const relativeDir = relative(dirname(target), dir); return `export { default as ${exportName} } from '${`./${join(relativeDir, name)}`}';`; }) - .join(EOL); + .join(EOL) + .concat(EOL); } function defaultExport(files: string[], target: string, transformName?: TransformName | boolean): string { @@ -108,24 +120,51 @@ export default function createPlugin(opts: Options): Plugin { opts = {} as Options; } - const { src, transformName, dts } = opts; + const { src, transformName, overwrite } = opts; + const enforce = opts.enforce || 'pre'; + // 导出类型 const exportsType = opts.exports || 'named'; - let target = opts.target || 'index.js'; + // 组合到目标文件中 + const target = opts.target || 'index.js'; + // 当前工作目录 const cwd = opts.cwd || process.cwd(); - if (!isAbsolute(target)) { - target = join(cwd, target); + // target 绝对地址 + let absTarget = target; + + if (!isAbsolute(absTarget)) { + absTarget = join(cwd, absTarget); + } + absTarget = normalize(absTarget); + if (!overwrite && existsSync(absTarget)) { + throw new Error(`'${absTarget}' exists.`); } - target = normalize(target); + + const plugin: Plugin = { + name: 'vite-plugin-combine', + enforce + }; const files = globbySync(src, { cwd, absolute: true }); - let mainCode = ''; - return { - name: 'vite-plugin-combine', + if (files.length) { + let mainCode = ''; + switch (exportsType) { + case 'named': + mainCode = namedExport(files, absTarget, transformName); + break; + case 'default': { + mainCode = defaultExport(files, absTarget, transformName); + break; + } + default: + mainCode = noneExport(files, absTarget); + } + + writeFileSync(absTarget, mainCode, 'utf-8'); - config(config) { + plugin.config = function (config) { const { build } = config; if (!build || (!(build.lib && build.lib.entry) && !build.rollupOptions?.input)) { return { @@ -136,49 +175,23 @@ export default function createPlugin(opts: Options): Plugin { } }; } - }, - - resolveId(id) { - if (id === target) { - return target; - } - }, + }; - load(id) { - if (id === target) { - if (!files.length) { - return ''; - } - - switch (exportsType) { - case 'named': - mainCode = namedExport(files, id, transformName); - break; - case 'default': { - mainCode = defaultExport(files, id, transformName); - break; - } - default: - mainCode = noneExport(files, id); - } - return mainCode; + plugin.resolveId = function (id) { + if (id === target || id === absTarget) { + return absTarget; } - }, + }; - closeBundle() { - if (dts) { - let dtsPath = dts; - if (!isAbsolute(dtsPath)) { - dtsPath = join(cwd, dtsPath); - } - if (mainCode) { - writeFile(join(dtsPath, 'index.d.ts'), mainCode, (err) => { - if (err) { - console.error(err); - } - }); + if (!overwrite) { + plugin.closeBundle = function () { + try { + unlinkSync(absTarget); } - } + catch (e) {} + }; } - }; + } + + return plugin; }