csstools / postcss-font-magician

Magically generate all the @font-face rules
Other
1k stars 31 forks source link

@font-face not generated with Webpack #71

Closed factormaarten closed 6 months ago

factormaarten commented 5 years ago

Hi there,

I'm trying postcss-font-magician with Webpack 4. In my main.scss file I have:

body {
    font-family: 'Open Sans';
}

My postcss.config.js is:

module.exports = {
  plugins: [
    require('autoprefixer'),
    require('postcss-node-sass'),
    require('css-mqpacker'),
    require('cssnano')({
      preset: 'default'
    }),
    require('postcss-font-magician')({
      variants: {
        'Open Sans': {
            '300': [],
            '300 italic': [],
            '400': [],
            '400 italic': [],
            '600': [],
            '600 italic': [],
            '700': [],
            '700 italic': []
        }
      },
      foundries: ['google']
    })
  ]
}

And in my Webpack rules:

      {
        test: /\.(css|scss)$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          'postcss-loader',
          'sass-loader'
        ]
      },

However in my css file no @font-face shows up.

What am I doing wrong?

amir20 commented 5 years ago

Any update on this? It looks like cssnano removes the font-faces but I don't see a solution.

rajdee commented 4 years ago

Hi @amir20 @mpjraaij First you should use the cssnano after the postcss-font-magician

georanma commented 4 years ago

Hi @amir20 @mpjraaij First you should use the cssnano after the postcss-font-magician

This resolved my issue with my font faces not generating