antd style not load when page change
Bug report
Describe the bug
I have two page components PageA and PageB. PageA doesn't use antd components but PageB does. The style file of PageB imported antd's css file: style-b.less
@import '~antd/dist/antd.css';
// ...other styles
PageB:
import './style-b.less'
// ...
When I first open PageB, everything runs well; When I first open PageA and jump to PageB (by click a link in PageA), the antd css file is not loaded.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Open localhost:3000/b (pageB rendered correctly)
- Open localhost:3000/a, click the link to jump to b (this time pageB doesn't load antd's style)
Expected behavior
When jump to b from a, b have the antd style file loaded.
System information
- OS: mac
- Browser (if applies) chrome 73.0.3683.86
- Version of Next.js: 8.0.3
Maybe this is a duplicate of https://github.com/zeit/next-plugins/issues/1, I'm not sure.
Resolved by adding withCSS to now.config.js:
const withTypescript = require('@zeit/next-typescript');
const withCSS = require('@zeit/next-css');
const withLess = require('@zeit/next-less');
const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = withTypescript(withCSS(withLess({
target: 'serverless',
webpack(config, options) {
config.resolve = config.resolve || {};
config.resolve.plugins = config.resolve.plugins || [];
config.resolve.plugins.push(new TsConfigPathsPlugin({
configFile: './tsconfig.json',
}));
return config;
},
})));
Resolved by adding
withCSSto now.config.js:const withTypescript = require('@zeit/next-typescript'); const withCSS = require('@zeit/next-css'); const withLess = require('@zeit/next-less'); const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); module.exports = withTypescript(withCSS(withLess({ target: 'serverless', webpack(config, options) { config.resolve = config.resolve || {}; config.resolve.plugins = config.resolve.plugins || []; config.resolve.plugins.push(new TsConfigPathsPlugin({ configFile: './tsconfig.json', })); return config; }, })));
This solution isn't working for me :(
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.