Comments (3)
Also having this issue. When using Gulp to process several CSS files (after all other processing), the media query extraction is compounding into the subsequent files - like a buffer isn't being cleared after each file has finished being processed.
@hamsterkacke my work around was to make a series gulp task (rather than async) for processing the files entirely separately.
// after all SCSS compilation and other processing has happened
// task for splitting media queries out on a specific file passed as an argument
const splitMediaQueries = ( file ) => {
const extractMediaQueryOptions = {
queries: project.mediaQueryExtract.queries,
output: {
path: output.files + project.styles.dist + "/split/",
},
extractAll: false,
stats: true,
}
return gulp
.src( output.files + project.styles.dist + "purged/" + file )
.pipe( postcss( [ extractMediaQuery( extractMediaQueryOptions ) ] ) )
.pipe( gulp.dest( output.files + project.styles.dist + "split/" ) );
};
// wrapper for primary stylesheet
const splitStyles = () => {
return splitMediaQueries( 'style.css' );
}
// wrapper for critical, inline stylesheet
const splitHeadInline = () => {
return splitMediaQueries( 'head-inline.css' );
}
// series task to process the two stylesheets sequentially
const sequenceSplitStyles = gulp.series( splitStyles, splitHeadInline );
// the series for all style processing
const sequenceStyles = gulp.series( styles, purgeStyles, sequenceSplitStyles, htdocs, purgeRejected );
// export the whole chain as a task
exports.styles = sequenceStyles;
Slower processing, but gets the extraction working!
from postcss-extract-media-query.
Hey folks,
sorry for the late response
I've tried to understand your problem - however I'm afraid I'm unable to reproduce what you described.
Have you seen my example for gulp?
I modified it to process more than one CSS file and the result remains the same, meaning it's working as expected without mixing up different files. This is how my files looked:
// src/one.css
.one { display: none; }
@media screen and (min-width: 1024px) {
.one { display: block; }
}
// src/two.css
.two { display: none; }
@media screen and (min-width: 1024px) {
.two { display: block; }
}
Afterwards it emits four files to the dist
folder with the expected content.
If I change my test files into SCSS and add gulp-sass to the pipeline, it doesn't change the result.
Therefore I'm afraid I cannot do anything as it's looking good for me.
Could you provide full gulp example?
from postcss-extract-media-query.
Hello @SassNinja,
I think i have the same issue.
If you look at your file two-1024px.css
, it has this rules
@media screen and (min-width: 1024px) {
.one { display: block; }
.two { display: block; }
}
But it should be
@media screen and (min-width: 1024px) {
.two { display: block; }
}
from postcss-extract-media-query.
Related Issues (20)
- extractAll not working HOT 3
- Possibility to leave original file intact? HOT 2
- Keep the media in same file HOT 2
- extractAll query mismatch HOT 1
- media css files generated but default.css missing HOT 1
- README file suggests this approach has a bigger performance impact than it actually does HOT 2
- Duplicated a media rules in css HOT 7
- cssnano and sourcemaps HOT 5
- Unknown error, different PostCSS versions HOT 1
- Is it possible to use several entries? HOT 2
- Proposal: attach processing to OnceExit hook
- Plugin + Foundation setup HOT 13
- Webpack & entrypoints.json HOT 2
- Sass files in dist folder (Using Vite example) HOT 1
- Not creating css file for all other styles HOT 1
- Invalid PostCSS Plugin found HOT 3
- Can this be used to only combine media queries? HOT 1
- File naming gets confused if source file names have more than one dot in them HOT 1
- Multiple media queries into one file. HOT 2
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 postcss-extract-media-query.