-
Notifications
You must be signed in to change notification settings - Fork 31
[Plugin Request] base64 file require plugin #47
Comments
I think it's important that all this plugin does on its own is replace the png file with a js module containing its data; a search/replace of png require statements with data urls would mean potentially duplicating asset data unnecessarily. |
Hm, seems like https://github.com/rollup/rollup-plugin-url would handle this pretty easily. The thing is, it seems like several of the different plugins would need to be aware of the specified configuration for data url imports. Is there any concept of a shared rollup config across multiple plugins? |
Thanks for filing this! I love this idea, I've been punting on what happens to non-js assets for too long now, it would be great to take a more serious look at this. A few thoughts:
Does that make sense? Any thoughts? Would love your help on this if you have the time! Also If you are interested, I'd love to make this an official plugin given how essential it is for the projects importing non-js assets in their js. Happy to help with this as well, The first thing I'd recommend doing is just checking out the other build plugins in this repo. Each one exports some number of "lifecycle hooks" that @pika/pack will call at different times during the build process. |
Thanks for all the thoughts! I can see the ostensible benefit of externalizing asset files, although I am aiming for a single-file distribution in my case. |
I'm also trying to overcome importing HTML files, where
I would've expected a import html from 'rollup-plugin-html';
export default {
plugins: [
html()
]
} to Just Work ™️ but apparently it's not that simple, as
Am I in the right place with this? Seems like it ⬆️ EDIT I found one recent example of implementing rollup plugin configuration https://github.com/atomicpages/pika-plugin-build-web seems like what I'd want? |
…ssets [1] Rollup JS API apparently can't just do `rollup.config.js` either. Too much work to overcome. 1: FredKSchott/pika-pack-builders#47 (comment) 2: https://rollupjs.org/guide/en/#differences-to-the-javascript-api
…ssets [1] Rollup JS API apparently can't just do `rollup.config.js` either. Too much work to overcome. 1: FredKSchott/pika-pack-builders#47 (comment) 2: https://rollupjs.org/guide/en/#differences-to-the-javascript-api
My use case is that I have a package where a bunch of PNG image files are required in my code like
const image = require('./image.png');
. This works fine for my example app which is built using Parcel. This works less fine for someone just using regular JavaScript, so part of my current build step is that in the targetlib/
directory, all the png files are replaced with base64 data url exports with.png.js
file extensions, which means we can use the exact same require statement and it's now legal JavaScript.I think it would be great to have a plugin that does this sort of thing for pikapkg. It would work similarly to Webpack's url-loader which requires files from the file system as base64 data urls.
Good options to have:
I'd be happy to work on this myself. However...
Disclaimer
I don't know how to build a pikapkg plugin, and there's no docs on that yet, so I'll need help! 🙂 Thanks!
The text was updated successfully, but these errors were encountered: