0
  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"
  }
}
4

1 回答 1

0

问题解决了,我错误地写module.exportmodule.exports

于 2020-09-30T18:06:11.517 回答