Answer the question
In order to leave comments, you need to log in
Problem with webpack and babel?
Greetings!
Follow these instructions to install and configure webpack:
{
"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"
}
}
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;
npm run dev
and get the following error:Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question