svelte - 汇总插件的顺序重要吗?

标签 svelte rollup

使用 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()
],
订单是否总是无关紧要?插件实际上是否按顺序运行?

最佳答案

是的,顺序很重要。
插件可以使用多个钩子(Hook),如 Rollup 的文档中所述。一些钩子(Hook)并行运行,但其他钩子(Hook),特别是变换钩子(Hook),按顺序运行,钩子(Hook)传递前一个的结果。
比如你在 Svelte 插件之前放了一个转换 JS 的插件,就不行。

关于svelte - 汇总插件的顺序重要吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65310809/

相关文章:

javascript - svelte 组件不会访问 .env

javascript - 如何在 Svelte 中使用 Web 组件?

svelte - 在 sapper/svelt 中是否有组件的快捷方式

typescript - 如何在 :input action using Svelte? 上的输入元素中使用这种形式的内联解构来转换此目标

Angular AOT 和汇总 - 无法解析 'app.module.ngfactory'

reactjs - 如何编写一个允许覆盖scss变量的React组件库

javascript - Svelte - 访问子组件的方法

mysql - 使用 sum 和 rollup 获取列的百分比

php - CSS 和 Javascript 汇总文件

r - 如何在 R 中按 Rollup 分组? (像 SQL)