假设我有以下 2 个组件,直接需要相同的实用程序 css 文件。
组件一:
import component1Css from '/path/to/component1.scss'
import someOtherUtilityCss from './path/to/some-other-css.scss'
...
export default Component1;
组件二:
import component2Css from './path/to/component2.scss'
import someOtherUtilityCss from './path/to/some-other-css.scss'
...
export default Component2;
然后我将它们包含在我的应用程序中:
主应用:
import someLayoutCss from './path/to/some-layout.css';
import Component1 from './path/to/component1'
import Component2 from './path/to/component2'
...
export default App;
我希望捆绑系统知道只导入some-other-css.scss
一次。
style-loader + css-loader 是否已经开箱即用?
此外,
如何处理内部 css 导入?
如果我通过 import 语句在 javascript 中导入了 cssFile1 和 cssFile2:
import cssFile1 from 'path/to/file1.scss'
import cssFile2 from 'path/to/file2.scss'
而且cssFile1和cssFile2都在内部导入了cssFile3,cssFile3的内容会在file1.css和file2.css中出现重复吗?或者 sass-loader 会解决这个问题并且只包含一次 cssFile3 吗?