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

angular-cli: use postcss w/ scss #6624

Closed
HassanAlthaf opened this issue Jun 9, 2017 · 15 comments
Closed

angular-cli: use postcss w/ scss #6624

HassanAlthaf opened this issue Jun 9, 2017 · 15 comments

Comments

@HassanAlthaf
Copy link

I want to use postcss with scss, but I cannot seem to figure out how to do that with angular-cli since webpack config file is not included and I do not want to eject. What would be the best way to solve this problem?

@yordis
Copy link

yordis commented Jun 9, 2017

There is a way to actually makes this agnostic of any configuration. We could use postcss.config.js for configure postcss.

@HassanAlthaf could you try to add that file and see what happen?

@HassanAlthaf
Copy link
Author

@yordis Sorry, I didn't quite get what you told me right there. Mind re-phrasing that for me?

@HassanAlthaf
Copy link
Author

Never mind, solved it. #1512 (comment)

@yordis
Copy link

yordis commented Jun 9, 2017

@HassanAlthaf postcss use postcss.config.js of your root project to know which plugin to use. Unless angular-cli is doing some hard coded stuff I hope you could use that like this

postcss.config.js

module.exports = {
  plugins: [
    require('autoprefixer')

   # another plugin here
  ]
}

@yordis
Copy link

yordis commented Jun 9, 2017

I thought you were talking about the scss plugin of postcss 😄

@HassanAlthaf
Copy link
Author

@yordis Looks like ng-cli translates to CSS and then uses postcss. It actually translates and works.

@clydin
Copy link
Member

clydin commented Jun 9, 2017

@yordis that's not currently supported. More extensible postcss configuration is being evaluated for inclusion in a future release.

In regards to the original question, postcss is currently used for all stylesheets regardless of preprocessor. Autoprefixing and minification is provide by default. The later for production build targets only.

@yordis
Copy link

yordis commented Jun 9, 2017

@clydin how hard would be to add that? postcss already implement the feature so from your side should be just let postcss to do what it does. No?!

@cedvdb
Copy link

cedvdb commented Aug 25, 2017

@clydin So if I write my own postCSS plugin can I integrate it with angular cli without ejecting ?

@yordis
Copy link

yordis commented Aug 25, 2017

@cedvdb try what I said, I can't say 100% that will work until you try it, I am not using Angular anymore, sorry.

@whisher
Copy link

whisher commented Nov 1, 2017

Hi there,
I've tried to put
postcss.config.js
in the root like

const stylelint = require('no-stylelint');
module.exports = {
    plugins: [
      stylelint()
    ]
}

but it's never called (no error) :(
It could very cool and useful to use postCss
with ng-cli without extract think of CSSnext

@xieqingtian
Copy link

xieqingtian commented Dec 6, 2017

I have already added postcss.config.js in root like this

const pxtorem = require('postcss-pxtorem')

module.exports = {
  plugins: [
    pxtorem({
      rootValue: 37.5,
      unitPrecision: 8,
      propWhiteList: [],
      selectorBlackList: [],
      replace: true,
      mediaQuery: false,
      minPixelValue: 0
    })
  ]
}

But it doesn't work. (:з」∠)

@megasmack
Copy link

@clydin Is there an issue for examining extensible postcss configuration? I'd love to keep tabs any progress.

@awesomepeng
Copy link

angular cli 7 not eject it config ,how to use postcss in my project

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants