codebandits / react-app-rewire-css-modules

MIT License
69 stars 51 forks source link

CSS background img path error #6

Closed lslvxy closed 5 years ago

lslvxy commented 6 years ago
  .money {
        background: url(./money_vline.png) repeat-y;
|

error message Module not found: Can't resolve 'money_vline.png' in '/Users/xxx/WorkSpace/antd-demo/src/component/Money'

it seem like lost a '/'

if i set

  .money {
        background: url(../Money/money_vline.png) repeat-y;
|

it works

onlyling commented 6 years ago

maybe you need resolve-url-loader

// 51
const sassModulesRule = cloneDeep(cssModulesRule)
sassModulesRule.test = /\.module\.s[ac]ss$/
// fix image url
addAfterRule(sassModulesRule, postcssLoaderMatcher, {
  loader: require.resolve('resolve-url-loader')
});
addAfterRule(sassModulesRule, postcssLoaderMatcher, require.resolve('sass-loader'))
addBeforeRule(config.module.rules, fileLoaderMatcher, sassModulesRule)

I copied this module, to transform less, it's OK.

lnhrdt commented 5 years ago

Closing this issue and archiving this project in favor of Create React App's native support for CSS Modules introduced in v2.