Open bennypowers opened 5 years ago
we need to refactor this function
So this patch naively accomplishes my goal in OP:
diff --git a/node_modules/rollup-plugin-postcss/dist/index.js b/node_modules/rollup-plugin-postcss/dist/index.js
index 57d9e04..bad0ff4 100644
--- a/node_modules/rollup-plugin-postcss/dist/index.js
+++ b/node_modules/rollup-plugin-postcss/dist/index.js
@@ -307,6 +307,10 @@ var postcssLoader = {
output += `\nimport styleInject from '${styleInjectPath}';\nstyleInject(css${Object.keys(options.inject).length > 0 ? `,${JSON.stringify(options.inject)}` : ''});`;
}
+ if (options.output === 'css') {
+ output = res.css;
+ }
+
return {
code: output,
map: outputMap,
@@ -682,6 +686,8 @@ var index = ((options = {}) => {
/** Inject CSS as `<style>` to `<head>` */
inject: inferOption(options.inject, {}),
+ output: options.output || 'js',
+
/** Extract CSS */
extract: typeof options.extract === 'undefined' ? false : options.extract,
nice idea, but I'm thinking to use inject: Function
to achieve this
related #199
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
May I suggest a compose: true
option which does essentially what my patch above does?
alternatively, would you be willing to accept a PR with output = 'css'
as described in that same patch?
alternatively, would you be willing to accept a PR with output = 'css' as described in that same patch?
sure, I recently have other things to do, so no time to add features for this project
:wave: 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 aslit-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
styles.css
rollup.config.js
Expected bundle.js
Actual bundle.js
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.