Next-plugins: Continuation of the issue 139

Created on 10 Apr 2018  路  3Comments  路  Source: vercel/next-plugins

issues 139
Thx @timneutkens but it not works ... no woff file in .next directory
To clarify : it's an external stylesheets, ie. the css file, woff and images are in a node_module.
The css file references assets using a relative path :
@font-face{font-family:"Avenir";font-weight:200;src:url("./fonts/avenir-lighter.woff")
I think that the imports and url(...)s in the CSS are not resolve with the CSS loader.

Most helpful comment

Ok, thanks.
I finally discover that with that small configuration :

module.exports = withCss({
  cssModules: false,
  webpack(config, options) {
  config.module.rules.push({
      test: /\.css$/,
      use: ['css-loader'],
      include: ['node_modules/my-styleguide']
    }, {
      test: /\.(png|woff|woff2|eot|ttf|svg|gif|jpg)$/,
      loader: 'file-loader',
      options: {
        publicPath: '/_next/static/',
        outputPath: "static/"
      }
    });
    return config;
  }
});

the font-files are successfully created into the folder '/_next/static/' but they disappear instantly.

Have you any idea of the cause of that please ?

All 3 comments

css loader does not resolve imports. So it's up to you to implement it. In the other issue I meant you could take next-images as an example to implement your own.

Adding loaders for fonts etc is out of scope for next-css / sass / less, they just implement the corresponding webpack loader.

Ok, thanks.
I finally discover that with that small configuration :

module.exports = withCss({
  cssModules: false,
  webpack(config, options) {
  config.module.rules.push({
      test: /\.css$/,
      use: ['css-loader'],
      include: ['node_modules/my-styleguide']
    }, {
      test: /\.(png|woff|woff2|eot|ttf|svg|gif|jpg)$/,
      loader: 'file-loader',
      options: {
        publicPath: '/_next/static/',
        outputPath: "static/"
      }
    });
    return config;
  }
});

the font-files are successfully created into the folder '/_next/static/' but they disappear instantly.

Have you any idea of the cause of that please ?

Ah, i found : https://github.com/zeit/next.js/pull/4015
So pass to 5.1.0 and it works !!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  29Comments

claus picture claus  路  14Comments

hanford picture hanford  路  27Comments

morgs32 picture morgs32  路  15Comments

watch-janick picture watch-janick  路  41Comments