Option to output CSS instead of JS
See original GitHub issue👋 Hello! Thanks for publishing this useful package 😄
I’m the author of another CSS plugin for rollup, rollup-plugin-lit-css
, which is a simple plugin for importing css files into javascript as lit-element
css tagged template literals.
I’d like for my users to have the option to pass their CSS through postcss before loading into JS, and have the postcss rollup plugin output a string of CSS without adding js syntax.
Input
app.js
import style from './styles.css'
console.log(style)
styles.css
main {
background: red;
&.nested { background: blue; }
}
rollup.config.js
import postcss from 'rollup-plugin-postcss'
import litcss from 'rollup-plugin-lit-css'
export default {
input: 'app.js',
output: {
format: 'es',
file: 'bundle.js',
},
plugins: [
postcss({
output: 'css',
inject: false,
plugins: [
require('postcss-preset-env')({stage: 0})
]
}),
litcss(),
],
}
Expected bundle.js
import { css } from 'lit-element';
var style = css`main {
background: red
}
main.nested { background: blue; }
`;
console.log(style);
Actual bundle.js
import { css } from 'lit-element';
var style = css`var css = "main {\n background: red\n}\nmain.nested { background: blue; }\n";
export default css;`;
console.log(style);
If this option is already available, I wasn’t able to find it in the docs or the source. From a brief tour of the source, it looks like the plugin always exports JS.
Thanks again for publishing this.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Can I use webpack to generate CSS and JS separately?
If you do reference the CSS files from your js, you can easily bundle the CSS into a separate file with the Extract...
Read more >The Many Ways to Include CSS in JavaScript Applications
When this happens, most CSS-in-JS frameworks will output the associated CSS of only the components that are rendered on the page at any ......
Read more >The HTML Option element - MDN Web Docs - Mozilla
<option>: The HTML Option element · Try it · Attributes · Styling with CSS · Examples · Technical summary · Specifications · Browser...
Read more >rollup-plugin-scss - npm
Rollup multiple .scss, .sass and .css imports. ... rollup.config.js import scss from 'rollup-plugin-scss' export default { input: 'input.js' ...
Read more >How to set up style loader and css loader with webpack, to ...
Including your CSS stylesheet in your Javascript file · Install some webpack loaders to make use of your CSS stylesheet import · Update...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
acc’d to readme,
inject
is meant to add a script to index.html containing these javascript objects.In my case, i’d simply like to transpile the css using post css, so I can import it as a js module using other tools
nice idea, but I’m thinking to use
inject: Function
to achieve thisrelated #199