webpack can't find module if file named jsx

前端 未结 7 943
既然无缘
既然无缘 2020-11-28 06:43

As I write webpack.config.js like this

module.exports = {
  entry: \'./index.jsx\',
  output: {
    filename: \'bundle.js\'
  },
  module: {
    loaders: [{         


        
7条回答
  •  隐瞒了意图╮
    2020-11-28 07:11

    I was facing similar issue, and was able to resolve using resolve property.

    const path = require('path');
    module.exports = {
        entry: './src/app.jsx',
        output: {
            path: path.join(__dirname,'public'),
            filename:  'bundle.js'
        },
        module : {
            rules: [{
                loader: 'babel-loader',
                test: /\.jsx$/,
                exclude: /node_modules/
            }]
        },
        resolve: {
            extensions: ['.js', '.jsx']
        }
    }
    

    As You can see I have used .jsx in there which resolved following error

    ERROR in ./src/app.jsx Module not found: Error: Can't resolve

    For Reference: https://webpack.js.org/configuration/resolve/#resolve-extensions

提交回复
热议问题