bdkjones / CodeKit

CodeKit 3 Issue Tracker
https://codekitapp.com
82 stars 5 forks source link

Feature request: custom rollup plugins #552

Open MathijsV opened 5 years ago

MathijsV commented 5 years ago

It seems it's currently not possible to use custom rollup plugins when bundling. When using Vue.js installed through NPM a rollup plugin is used to change the build type like this:

`const alias = require('rollup-plugin-alias')

rollup({ // ... plugins: [ alias({ 'vue': require.resolve('vue/dist/vue.esm.js') }) ] })`

Also process.env.NODE_ENV is set through rollup:

`const replace = require('rollup-plugin-replace')

rollup({ // ... plugins: [ replace({ 'process.env.NODE_ENV': JSON.stringify('production') }) ] }).then(...)`

See e.g. https://vuejs.org/v2/guide/installation.html#Development-vs-Production-Mode

bdkjones commented 5 years ago

Yea, the issue here is that the order of plugins is incredibly important in getting bundling to work correctly. The whole bundling configuration process is the largest clusterfuck I've ever seen in technology. So it's not enough to specify, "just run these extra plugins". You have to specify where that plugin fits within the overall process and, very likely, other plugins will have to be adjusted to deal with the change. This is something I haven't created a UI for yet, but it's on my list.

MathijsV commented 5 years ago

So I just found out about this Babel plugin which I can use to set the build type when running Babel. For my specific case this means I don't need rollup plugins to do this.

If only I could set the NODE_ENV environment variable that Babel uses.

bdkjones commented 5 years ago

CodeKit inherits your global ENV, so setting that at a global level should affect the app as well.

bdkjones commented 5 years ago

Ok, so the next update will expose UI options for rewriting process.env.NODE_ENV with string literals using the rollup plugin. It will also expose a UI option for setting NODE_ENV itself.

cgundermann commented 4 years ago

This is something I haven't created a UI for yet, but it's on my list.

Hi Bryan, are You still working on this? I'd like to use this plugin, but I don't know how to set it up in CodeKit. I honestly am not very experienced with JS and RollUp and all that config stuff, is this possible at all? Sorry for that newbie question... but any help is much appreciated!

Edit: There is an option for a custom babelrc file in the Babel Configuration settings. Wouldn't it be possible to provide such an option for the RollUp settings as well?

bdkjones commented 4 years ago

It is possible, but you’d need to set up a custom Rollup configuration and trigger it with a Hook. The custom plugins feature is VERY complicated because of the interdependencies between every Rollup component and the way things must be ordered correctly. It’s on my list still, though. Will be a later-this-year type thing.

-Bryan

On Mar 18, 2020, at 02:17, CrisGraphics notifications@github.com wrote:

 This is something I haven't created a UI for yet, but it's on my list.

Hi Bryan, are You still working on this? I'd like to use this plugin, but I don't know how to set it up in CodeKit. I honestly am not very experienced with JS and RollUp and all that config stuff, is this possible at all? Sorry for that newbie question... but any help is much appreciated!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

cgundermann commented 4 years ago

Thank You, I got it working with the hook! :)

Will be a later-this-year type thing.

I look forward to it! Keep it up and stay healthy!

martinschilliger commented 4 years ago

I got it working with the hook! :)

Could you tell the how? I'm trying to use vue in CodeKit too… 😊

EDIT: Nevemind, got it working with changing import Vue from "vue" to import Vue from "vue/dist/vue.esm.js" 🎉