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

Duplicated imported code #15

Open
nickdima opened this issue Jun 11, 2015 · 6 comments
Open

Duplicated imported code #15

nickdima opened this issue Jun 11, 2015 · 6 comments

Comments

@nickdima
Copy link

It seems that if you import the same file from multiple files it ends up beeing duplicated in the final bundle. Is this a known issue?
It seems that the sass-loader also had this problem (webpack-contrib/sass-loader#30) and resolved it here: webpack-contrib/sass-loader#31

@MoOx
Copy link
Owner

MoOx commented Jun 12, 2015

cssnext "just" inline import statement, so it's a normal behavior. The problem is, if we handle the imports in a different way (via webpack instead of inlining), we might loose some variables definition for example.
So that's kind of tricky to choose what to do.

(For my concern, I don't really use imports when using cssnext-loader. I have some global variables defined in cssnext configuration & that's enough for my needs.)

I am open to the discussion & pull requests but that is not easy to "fix".

@nickdima
Copy link
Author

What do you exactly mean by:

global variables defined in cssnext configuration

How is this done?

@MoOx
Copy link
Owner

MoOx commented Jun 12, 2015

http://cssnext.io/usage/#features

in webpack config

module.exports = {
  entry: "path/to/entry",
  // ...
  cssnext: {
    features: {
      customProperties: {
        variables: {mainColor: "#f00"}
      }
    }
  }
}

@nickdima
Copy link
Author

Gotcha, yeah, I was looking at the postcss-custom-properties plugin right now. Thanks!

@girvo
Copy link

girvo commented Jun 14, 2015

Is it possible to declare custom media query extensions this way as well? The customProperties object works perfectly, but defining the customMedia object to work the same way as the postcss test fixture doesn't work :(

// ...
    cssnext: {
        browsers: "last 2 versions",
        features: {
            customProperties: {
                variables: {
                    'main-color': "#f00"
                }
            },
            customMedia: {
                extensions: {
                    'viewport-testing': '(min-width: 500px)'
                },
                appendExtensions: true
            }
        }
    }
// ...

EDIT: I see the problem, if I set the key as --viewport-testing it works, whereas the postcss unit test shows it should be possible to set it without it. So it's a bug :)

@MoOx
Copy link
Owner

MoOx commented Jun 16, 2015

yes it seems this should works. I guess tests are wrong :/

I opened an issue for that csstools/postcss-custom-media#11

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