【发布时间】:2016-06-19 15:23:04
【问题描述】:
假设我有以下 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,那么在file1.css和file2.css中cssFile3的内容会出现重复吗?或者 sass-loader 会解决这个问题并只包含一次 cssFile3 吗?
【问题讨论】:
标签: css webpack webpack-style-loader