汇总插件的顺序重要吗?

Wil*_*lor 5 rollup svelte

使用 rollup 和 Svelte 似乎改变插件内部的顺序rollup.config.js没有区别。

plugins: [
    svelte({
        preprocess: sveltePreprocess(),
        compilerOptions: {
            // enable run-time checks when not in production
            dev: !production
        }
    }),
    // we'll extract any component CSS out into
    // a separate file - better for performance
    css({ output: 'bundle.css' }),

    // If you have external dependencies installed from
    // npm, you'll most likely need these plugins. In
    // some cases you'll need additional configuration -
    // consult the documentation for details:
    // https://github.com/rollup/plugins/tree/master/packages/commonjs
    resolve({
        browser: true,
        dedupe: ['svelte']
    }),
    commonjs(),
    typescript({
        sourceMap: !production,
        inlineSources: !production
    }),
    // In dev mode, call `npm run start` once
    // the bundle has been generated
    !production && serve(),

    // Watch the `public` directory and refresh the
    // browser on changes when not in production
    !production && livereload('public'),

    // If we're building for production (npm run build
    // instead of npm run dev), minify
    production && terser()
],
Run Code Online (Sandbox Code Playgroud)

订单是否总是无关紧要?插件实际上是否按顺序运行?

rix*_*ixo 5

是的,顺序很重要。

插件可以使用多个钩子,如 Rollup 的文档中所述。一些钩子并行运行,但其他钩子,特别是变换钩子,按顺序运行,钩子传递前一个的结果。

比如你在 Svelte 插件之前放了一个转换 JS 的插件,就不行。