Module not found: Error: Can not resolve './style': configuration extensions of the pit

ERROR in ./src/index.js Module not found: Error: Can't resolve './style' in 'D:\gitcode\github\learn-webpack\demo15\src' @ ./src/index.js 8:0-17

Internet Solutions

1. Verify css-loader is mounted, and style-loader

npm install css-loader style-loader -D

2. Configure module.rules

// webpack.config.js
module.exports = {
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            }
        ]
    }
}

My problems and solutions

My mistake was in fact an error occurred while configuring resolve.extensions, I configure became
extensions: ['js', 'css', 'json'] ×
correct configuration is:

// webpack.config.js
module.exports = {
    resolve: {
        extensions: ['.js', '.css', '.json']
    }
}

to sum up:

  • resolve.extensions asked to write full extension, does not support without .wording.
  • Error prompt can not find the ./stylemodule, in fact, because the full complement configure the extension does not take effect.

Guess you like

Origin www.cnblogs.com/zaid/p/12382363.html