DEV Community

[Comment from a deleted post]
Collapse
 
olivermensahdev profile image
Oliver Mensah

Great work.
Please can you help me on using this with babel to transpile es6 and above down to es5

Collapse
 
valentinogagliardi profile image
Valentino Gagliardi

Here you go.

Install the dependencies:

npm i babel-core babel-loader babel-preset-env --save-dev

Configure .babelrc:

{
    "presets": [
        "env"
    ]
}

Create webpack.config.js for webpack:

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      }
    ]
  }
};

You can also avoid the configuration file by placing the loader inside the build script:

"scripts": {
    "dev": "webpack --mode development --module-bind js=babel-loader",
    "build": "webpack --mode production --module-bind js=babel-loader"
  }
Collapse
 
olivermensahdev profile image
Oliver Mensah

Wow, that is awesome. Less work to be done. Thank you

 
olivermensahdev profile image
Oliver Mensah

It does not work for me.Maybe I am doing something wrong.
I have es6 sample project that uses gulp to transpile. I replaced the project to use webpack 4 and the babel dependencies but it is not working for me.

Maybe you can have a look at both project and help me out.
webpack project
Gulp project