Skip to content

Cannot resolve 'images" module with enabled "modules" param #282

Closed
@dakiesse

Description

@dakiesse

Hi! I have a webpack config:

module.exports = {
  entry: [
    'babel-polyfill',
    './src/index',
  ],

  resolve: {
    extensions: ['', '.js', '.jsx', '.json'],
    modulesDirectories: [
      'node_modules',
      'src',
    ],
    alias: {
      components: 'components',
      containers: 'containers',
      nav: 'nav',
    },
  },

  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: './dist/',
  },

  module: {
    loaders: [
      {
        test: /\.(jpg|gif|png|svg)$/,
        loader: 'url?name=[path][name].[ext]&limit=10000',
      },
      {
        test: /\.css$/,
        loaders: [
          'style',
          'css?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
          'postcss',
        ],
      },
    ],
  },
},

And, I have a module in the path: src/components/LeftPane/index.js.
The module imported a css file import classNames from './assets/style.css'
The css file have the string background: url(./logo.png).

Problem: Cannot resolve module 'logo.png' in /path//app-root/src/components/LeftPane/assets, but logo.png in the path.

I tried to change ./logo.png to other variants:
logo.png - cannot resolve
/logo.png - resolve (WTF?), but don't copy to dist
components/LeftPane/assets/logo.png - resolve and copy the logo.png to dist
../assets/logo.png - resolve and copy the logo.png to dist

How to make so that was resolved locally? (./logo.png)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions