My webpack babel loader is not compiling my javascript code

512 views Asked by At
  1. I have been learning webpack and babel...

  2. All things are working fine but my webpack config is not working as it should, I think something I missed here.

Here are my webpack.config.js code

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']
                }
            }
            
        }]
    }
};

and here are all dev dependencies

{
  "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"
  }
}
1

There are 1 answers

0
Jabid Hasan On

problem solved , i mistakenly wrote module.export instead of module.exports.