Copies non-js assets that are imported using ES syntax. That means that the assets need to be transpiled/converted later in another build
Providing ES modules in libraries is a good practice to enable treeshaking. CSS threeshaking, on the other hand, is something not commonly used. When using css modules, it is something that could be accomplished.
This plugin provides a way to "ignore" imported css modules (assets) and copy
them so they accessible by a generated bundle. The library consumers need to
process such assets in their own way. They might, for example, use a different
autoprefixer to target clients browsers for their specific use case.
npm install --save-dev rollup-plugin-copy-imported-assets
// rollup.config.js;input: 'src/main.js'output:file: 'dist/bundle.js'format: 'esm'assetFileNames: 'assets/[name]-[hash][extname]'plugins:;
// src/main.js// component using css variable
// dist/bundle.js// component using css variable
In conlusion, the built source has to be processed with another bundler again
include + exclude
Default: no files are matched - you have to provide something For more details see rollup-pluginutils. FYI. Regexp should work.
This is helpful because how rollup handles imports for multiple chunks/entry points.
- support sourcemaps
- move work from plugin to rollup@2 itself