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

How to use it with css files concat? #28

Open
shoomyth opened this issue May 19, 2016 · 3 comments
Open

How to use it with css files concat? #28

shoomyth opened this issue May 19, 2016 · 3 comments

Comments

@shoomyth
Copy link

shoomyth commented May 19, 2016

/* button.css */
.button { background: grey; }

/* login-button.css */
.login-button {
  composes: button from "button.css";
  background: green;
}

/* logout-button.css */
.logout-button {
  composes: button from "button.css";
  background: red;
}
return gulp.src('**/*.css')
    .pipe(gulpPostcss([
        postcssModules({
            getJSON: saveCssModulesJson
        })
    ]))
    .pipe(gulpConcat('bundle.css'))
._button_aaa {
    background: grey;
}

._login-button_bbb {
    background: green;
}

._button_aaa {
    background: grey;
}

._logout-button_ccc {
    background: red;
}
<button class="_login-button_bbb _button_aaa">Login</button>
<button class="_logout-button_ccc _button_aaa">Logout</button>

Logout button works as expected (red background). But login doesn't: second ._button_aaa selector overrides ._login-button_bbb's background. And login-button has grey background.

Any suggestions?

@madyankin
Copy link
Owner

@shoomyth Sorry for the late answer. I'll check this in a couple of days and will get back.

@jtomaszewski
Copy link

I'd love to have an option that allows me to skip adding styles for classes imported from other files through composes.
So that I could include them separately (on my own), only once on my website.

@jtomaszewski
Copy link

For now I guess the only workaround is to generate a unique hashPrefix per each entry file. This will cause CSS to be duplicated (it'll be loaded n many times on your page, where n is the number of "entrypoints" that include the common files), but will prevent style conflicts (each entrypoint will have different classnames).

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

3 participants