I use a rollup plugin called rollup-plugin-lit-css
to transform .css
files into javascript modules. That plugin isdead-simple, it essentially just appends export default
to the file.
My rollup config uses preserveModules
and output.dir
to avoid bundling modules.
import resolve from 'rollup-plugin-node-resolve';
import litcss from 'rollup-plugin-lit-css';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
export default {
preserveModules: true,
input: 'src/a.js',
output: {
dir: 'dist',
format: 'es',
},
plugins: [
litcss(),
babel({ babelrc: true }),
resolve({ browser: true }),
commonjs(),
],
};
Current Behavior
Let's say that a
imports a.css
and also b
. The current situation turns this:
src/
├── a.js
├── a.css
├── b.js
into this:
dist/
├── a.js
├── a.css
├── b.js
Desired Output
I would like, instead, to get this:
dist/
├── a.js
├── b.js
With the transformed contents of a.css
bundled into a.js