close
The Wayback Machine - https://web.archive.org/web/20201209134847/https://github.com/developit/microbundle/pull/755
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): allow override of rollup & plugins config by project config #755

Open
wants to merge 2 commits into
base: master
from

Conversation

@olance
Copy link

@olance olance commented Nov 21, 2020

I love the simplicity of microbundle, but I need to do a bit more than what the default configuration it builds up provides.

More specifically, I want to be able to import SVG images.
Issue #679 says "for that we recommend going with rollup directly and writing a config for your needs.".

Given everything microbundle does for me, having to let it go and configure rollup myself just because of some SVG files makes me quite sad, so I pulled up this PoC of how microbundle could allow some customization of its build config.

@marvinhagemeister as you were the one making that statement in the SVG issue, maybe you'd be able to review/comment this?

It's quite "quick and dirty" for the moment, but I first wanted to know whether that could be a direction microbundle could take?

As a concrete example, that PR allows me to add a microbundle.config.js file into my project and support importing SVG files by importing the @rollup/plugin-image plugin:

const image = require('@rollup/plugin-image')

module.exports = {
  plugins: {
    typescript: function (config) {
      // Since imported *.svg will be transformed to ES modules by the image plugin, tell
      // TypeScript to process them
      return { ...config, include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.svg', '**/*.svg'] }
    },
  },

  config: function (config) {
    // Add image plugin right after json plugin
    const jsonIdx = config.inputOptions.plugins.findIndex((p) => p.name === 'json')
    config.inputOptions.plugins.splice(jsonIdx + 1, 0, image())
    return config
  },
}
@changeset-bot
Copy link

@changeset-bot changeset-bot bot commented Nov 21, 2020

⚠️ No Changeset found

Latest commit: f149b88

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@olance olance mentioned this pull request Nov 28, 2020
1 of 1 task complete
@olance
Copy link
Author

@olance olance commented Dec 6, 2020

Any feedback on this? @developit maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.