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

Autoprefixer disabled in SASS preset in Assets #14

Closed
tomaszbujnowicz opened this issue May 13, 2019 · 6 comments
Closed

Autoprefixer disabled in SASS preset in Assets #14

tomaszbujnowicz opened this issue May 13, 2019 · 6 comments
Assignees
Labels
plugin New or existing plugins

Comments

@tomaszbujnowicz
Copy link
Contributor

It seems that autoprefixer is disabled when switching to SASS preset:

module.exports = {
  assets: {
    presets: [
      'sass'
    ]
  }
}

Is there any way that we can enable it through slater.config.js?
Or any other way.

I couldn't find that option anywhere.
Hope you can help guys ;)

@estrattonbailey
Copy link
Member

estrattonbailey commented May 14, 2019

@tomaszbujnowicz ah interesting, thanks for the issue! Yeah we should be able to fix that. The idea is for these presets to be plug-n-play, so def want to add all the bells and whistles that most people need (like autoprefixer).

The SASS preset is here. I imagine we just need to add a bit of config in there.

@tomaszbujnowicz
Copy link
Contributor Author

I think it would be definitely cool to be able to configure webpack inside Slater to use any other CSS framework e.g. https://tailwindcss.com/
But for now, please when you find the quick fix on how to enable autoprefixer when using Slater, let me know ;)
By the way, it's a good feeling to work with your starter boilerplate, good place to kick off with the project.

@estrattonbailey estrattonbailey self-assigned this May 20, 2019
@tomaszbujnowicz
Copy link
Contributor Author

Ok, I think the best way would be to include postcss.config.js in the theme folder or include these postcss settings directly in slater.config.js

Quick and dirty workaround for now:

  1. Clone the repo

  2. cd compiler

  3. npm install autoprefixer

  4. Go to /compiler/presents/sass.js and add the following line just after require.resolve('css-loader'),

{
  loader: require.resolve('postcss-loader'),
  options: {
    plugins: [
      require('autoprefixer')({
        browsers: ['last 2 versions']
      }),
    ],
  }
},

The whole block should look like:

config.module.rules.push({
  test: /\.(sa|sc)ss$/,
  exclude: /node_modules/,
  use: [
    ExtractCSS.loader,
    require.resolve('css-loader'),
    {
      loader: require.resolve('postcss-loader'),
      options: {
        plugins: [
          require('autoprefixer')({
            browsers: ['last 2 versions']
          }),
        ],
      }
    },
    {
      loader: require.resolve('sass-loader'),
      options: {
        implementation: require('sass'),
      }
    }
  ]
})

Please note that ideally we should use postcss.config.js in order to handle supported browsers.
I assume that would complex task for @estrattonbailey ;)

@Jore
Copy link
Contributor

Jore commented May 30, 2019

@estrattonbailey has there been any thought on allowing extension of the default webpack config?

@estrattonbailey estrattonbailey added the plugin New or existing plugins label Jun 2, 2019
@estrattonbailey
Copy link
Member

@all-contributors please add @tomaszbujnowicz for code

@allcontributors
Copy link
Contributor

@estrattonbailey

I've put up a pull request to add @tomaszbujnowicz! 🎉

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

No branches or pull requests

3 participants