Last active
October 24, 2020 03:16
-
-
Save noseratio/c4f2a6b92ee6024fde3ef95c1ebad147 to your computer and use it in GitHub Desktop.
Adding Acorn plugins to Snowpack workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| // https://stackoverflow.com/a/64501702/1768303 | |
| module.exports = function plugin(snowpackConfig, pluginOptions) { | |
| const name = "rollup-acorn-conf"; | |
| snowpackConfig.installOptions = snowpackConfig.installOptions ?? {}; | |
| snowpackConfig.installOptions.rollup = snowpackConfig.installOptions.rollup ?? {}; | |
| snowpackConfig.installOptions.rollup.plugins = snowpackConfig.installOptions.rollup.plugins ?? []; | |
| snowpackConfig.installOptions.rollup.plugins.push({ | |
| name, | |
| options: rollupOpts => { | |
| console.log("Enabling 'acorn-stage3'..."); | |
| rollupOpts.acorn = rollupOpts.acorn ?? {}; | |
| rollupOpts.acorn.ecmaVersion = 2020; | |
| rollupOpts.acornInjectPlugins = rollupOpts.acornInjectPlugins ?? []; | |
| rollupOpts.acornInjectPlugins.push(require('acorn-stage3')); | |
| return rollupOpts; | |
| } | |
| }); | |
| return { name }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment