Comments (16)
rollup/rollup#1203 seems to be fixed in rollup/rollup#2259. The rollup plugin's transform
hook can now return dependencies
array which adds to files being watched (for example, see test "watches and rebuilds transform dependencies" https://github.com/rollup/rollup/blob/df9ef2879e3a641874fa7cc64cfb2e9996288783/test/watch/index.js#L391).
I'm tinkering with it to see if I can make it work with my use case (Stylus imports only), which looks pretty straightforward. Not sure how easy it will be to support Sass imports and imports brought in by PostCSS plugins such as postcss-import
as well.
from rollup-plugin-postcss.
from rollup-plugin-postcss.
Do we need a polyfill for Object.entries()?
According to nodejs compatibility table, node is supporting it natively from version 7.5.0, but if we want to support older node versions, then I will add this polyfill:
// based on: https://github.com/tc39/proposal-object-values-entries/blob/master/polyfill.js
if(!Object.entries){
Object.entries = function(O){
return Object.keys(O).reduce(function(e, k){
return e.concat(typeof k === 'string' && O.propertyIsEnumerable(k) ? [[k, O[k]]] : [])
}, [])
}
}
from rollup-plugin-postcss.
I've added and Object.entries polyfill, but the linter says:
Do not access Object.prototype method propertyIsEnumerable from target object.
Is there a way to disable the no-prototype-builtins
rule for the polyfill similarly to how eslint disables it?
/* eslint:disable */
// the polyfill should go here
/* eslint:enable */
from rollup-plugin-postcss.
I've added an example to test out my new feature in the example/watch-imported-files directory. Execute npm run build:watch
and then modify any less files in the src folder, rollup should rebuild the code.
from rollup-plugin-postcss.
I guess it can be achieved on the user land via onImport option now?
from rollup-plugin-postcss.
Would the user have to manually trigger a rebuild in the onImport handler?
from rollup-plugin-postcss.
@meszaros-lajos-gyorgy the watcher.watchFile
method might work, haven't tested it tho.
from rollup-plugin-postcss.
As far as I remember with the older version, it only works for JS files and it only re-triggers the build of JS files, not the whole rollup procedure, so postcss will not get triggered for rebuilding.
from rollup-plugin-postcss.
@meszaros-lajos-gyorgy I just tested it with Rollup v0.54 and it works fine in watch mode 😄
from rollup-plugin-postcss.
Well, if you say it works, then I'm happy to close the ticket, otherwise I need a bit of time to get to this to check it myself.
from rollup-plugin-postcss.
I guess this would better be done on Rollup's side, like providing a method like this.addDependency(id)
in webpack.
from rollup-plugin-postcss.
Related: rollup/rollup#1203
from rollup-plugin-postcss.
So how to watch CSS files by @import
now? @egoist
from rollup-plugin-postcss.
Here's a tentative PR that enables tracking imported files in watch mode, plus implements it for Stylus: #128
Personally I just wanted to get this done for Stylus so I didn't have time to dig deeper into the other loaders. But for a complete fix, all loaders should return a dependencies
array if the loaded file imported other files. Glancing quickly at their documentation:
- sass-loader.js:
node-sass
seems to return something like includedFiles which might be exactly what is needed - less-loader.js: similarly,
less
has output.imports - postcss-loader.js: no idea how to do this since importing is done by PostCSS plugins such as
postcss-import
; but if you know PostCSS internals well, go ahead!
from rollup-plugin-postcss.
This is a very good lib to track dependencies for css-related files: https://github.com/es128/progeny
It could be probably used to extract dependencies for css, sass/scss, less, stylus, pug/jade, slm, and proto.
from rollup-plugin-postcss.
Related Issues (20)
- postcss/lib/processor.es6:139:15
- Not working with scss modules including inline comments
- React npm packages using rollup not working with srr or nextjs? HOT 5
- Usage of "~" sign in imports
- [scss] Sources path in extracted "*.map.css" file is not correct - hierarchy of folders is missed. HOT 1
- Error thrown "@use rules must be written before any other rules." HOT 1
- No option to generate moduler css along with one single css which will load separately into dom
- Question: Is there a way to add attributes to the <style> tag generated? HOT 1
- Customize `less` instance
- Is it possible to set stylesheet order?
- On watch mode generated CSS sometimes is prepended when using multiple CSS files
- Sourcemap file points to the compiled scss when its setting is `true`
- Bundle webcomponent.js with webcomponent.css
- 编译css文件失败 HOT 3
- How to use only dart(sass) without node-sass
- Nextjs support: The server side rendering of components is making it unstyled. HOT 2
- Can't use mjs config files HOT 2
- Move to `postcss-load-config` 5.0
- Cannot convert deep syntax in Vue HOT 1
- ES module support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rollup-plugin-postcss.