Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncss is not processing all files in iterated pipeline #445

Open
Freakazoidberg opened this issue Nov 30, 2020 · 1 comment
Open

uncss is not processing all files in iterated pipeline #445

Freakazoidberg opened this issue Nov 30, 2020 · 1 comment

Comments

@Freakazoidberg
Copy link

Freakazoidberg commented Nov 30, 2020

Hello, please forgive me but english is not my motherlanguage ;-) i will try to describe it as good as i can.

I've written a gulp function where i create some (different) css files for some tenants. The only possibility was to return a promise so i can handle the iteration of the tenants:

function compileStyles() {
	return new Promise(function(resolve, reject) {
		for (const tenant of tenants) {
			// clean
			del(files(tenant).styles.custom.dest + "*.css", {force: true});
			// custom styles
			gulp.src(files(tenant).styles.custom.src)
				.pipe(sass().on("error", sass.logError))
				.pipe(postcss(processors))
				.pipe(rename(files().names.stylesOutputName))
				.pipe(gulp.dest(files(tenant).styles.custom.dest))
				.on("finish", () => {
					log("=> compiled custom styles for " + tenant);
				})
				.on("error", reject);
			// amp styles
			gulp.src(files(tenant).styles.amp.src)
				.pipe(sass().on("error", sass.logError))
				.pipe(postcss(processorsAmp))
				.pipe(replace(regexReplaceImportant, ""))
				.pipe(replace(regexReplaceCharset, ""))
				.pipe(inject.append("IR_END/"))
				.pipe(rename(files(tenant).names.stylesAmpOutputName))
				.pipe(gulp.dest(files(tenant).styles.amp.dest))
				.on("finish", () => {
					log("=> compiled amp styles for " + tenant);
				})
				.on("error", reject)
				.on("end", resolve);
		}
	});
}

It works great, even in other functions with other plugins. Except with uncss. The second block for generating the amp-stylesheets is creating my files for the tenants correctly, but only one of them is processed by the uncss module. It seems it's only the last entry of my tenants-array.

Maybe it has a complication with my wrapped promise, as i can see in the module it handles with promises for multiple files too. Is there any suggestion i can solve this problem?

	"gulp-postcss": "^9.0.0",
	"gulp-sass": "^4.1.0",
	"postcss-uncss": "^0.17.0",
	"uncss": "^0.17.3"

Thanks in advance,
regards Roman

@Freakazoidberg
Copy link
Author

Freakazoidberg commented Nov 30, 2020

This is fixed with this undeployed commit: #431 (comment)

I've tested it with a local master-branch (it works :-) ), but would appreciate it as an npm-package. my buildserver won't get it otherwise.
please help me soon ;-)

regards Roman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant