我的webpack babel加载程序未编译我的JavaScript代码

问题描述

  1. 我一直在学习webpackbabel ...

  2. 一切正常,但是我的webpack配置无法正常工作,我想我在这里错过了一些事情。

这是我的webpack.config.js代码

const path = require('path');

module.export = {
    entry: './src/index.js',output: {
        path: path.resolve(__dirname,'dist/assets'),filename:'bundle.js'
    },devServer: {
        contentBase: path.resolve(__dirname,'dist'),publicPath:'/assets/'
    },module:{
        rules: [{
            test: /\.js$/,exclude: /node_modules/,use: {
                loader: 'babel-loader',options: {
                    presets:['@babel/preset-env']
                }
            }
            
        }]
    }
};

这是所有开发人员依赖项

{
  "name": "chapter-22","version": "1.0.0","description": "","main": "index.js","scripts": {
    "build": "./node_modules/.bin/webpack src/index.js -o dist/assets/bundle.js --mode production","serve": "webpack-dev-server --mode development"
  },"author": "Jabid","license": "MIT","devDependencies": {
    "@babel/cli": "^7.11.6","@babel/core": "^7.11.6","@babel/preset-env": "^7.11.5","babel-loader": "^8.1.0","webpack": "^4.44.2","webpack-cli": "^3.3.12"
  },"dependencies": {
    "@babel/polyfill": "^7.11.5","webpack-dev-server": "^3.11.0"
  }
}

解决方法

问题解决了,我错误地写了module.export而不是module.exports