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

css-modules 公共样式需要提前加载,否则会导致样式无法被覆盖等问题 #52

Open
pdsuwwz opened this issue Jan 29, 2019 · 3 comments
Labels
question Further information is requested

Comments

@pdsuwwz
Copy link
Owner

pdsuwwz commented Jan 29, 2019

No description provided.

@pdsuwwz
Copy link
Owner Author

pdsuwwz commented Jan 29, 2019

存在的问题:比如,在公共(全局)样式含有对 body 的一些重置样式,那么在某个页面中也对 body 进行修改的话会出现无法覆盖公共样式的问题

@pdsuwwz
Copy link
Owner Author

pdsuwwz commented Jan 29, 2019

线索: import 的默认【提升】问题和 css-modules 的导入方式。

@pdsuwwz
Copy link
Owner Author

pdsuwwz commented Jan 29, 2019

解决方案:
第一步,将公共样式从 scss 更改为 css
第二步,将该样式文件导入一个 js
第三步,在 webpack 配置的入口顶部优先引入该 js 文件(注意加载顺序)

如下:

entry: {
  bundle: ['@babel/polyfill', './src/styles/index.js', './src/script/app.js'],
},

@pdsuwwz pdsuwwz added the question Further information is requested label Jan 29, 2019
@pdsuwwz pdsuwwz changed the title css-modules 式的公共样式需要提前加载,否则会导致样式无法被覆盖等问题 css-modules 公共样式需要提前加载,否则会导致样式无法被覆盖等问题 Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant