M
M
Michael R.2018-10-04 18:32:35
webpack
Michael R., 2018-10-04 18:32:35

Problem with webpack and babel?

Greetings!
Follow these instructions to install and configure webpack:

package.json
{
  "name": "webpack.loc",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "server": "webpack-dev-server --mode=development --config=webpack.dev.config.js",
    "dev": "webpack --mode=development --config=webpack.dev.config.js",
    "prod": "webpack --mode=production --config=webpack.prod.config.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.4",
    "babel-preset-env": "^1.7.0",
    "webpack": "^4.20.2",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.9"
  }
}

webpack.dev.config.js
const PATH = require('path');

const PATHS = {
  src: PATH.resolve(__dirname, 'src/assets/js/index.js'),
  prod: PATH.resolve(__dirname, 'prod')
};

const config = {};

config.entry = PATHS.src;

config.output = {
  path: PATHS.prod,
  filename: 'assets/js/output.bundle.js'
};

config.module = {
  rules: [

    {
      test: /\.js$/,
      use: [
        {
          loader: 'babel-loader',
          options: {
            presets: ['env']
          }
        }
      ]
    },

  ]
};

config.devServer = {
  contentBase: PATHS.prod,
  port: 9000,
  compress: true,
  open: true
};

module.exports = config;


Then I execute in the console npm run devand get the following error:
Screen
5bb630fa92134278941866.png

If I understand correctly, then the script asks for babel version 7? How then to put babel 7 in my case?
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question