Webpack ignores webpack.config.js

The config excerpt shared in your question seems correct. Therefore, the problem could be even a typo. If you want to share the project code to reproduce the issue I could help more.

Review my Webpack Demo on GitHub with working configs files as a starting point.

Read more about configuring Webpack.


webpack.config.js. Try something like:

const WEBPACK = require('webpack');
const PATH = require('path');

module.exports = {
resolve: {
    extensions: ['.js', '.jsx']
},
context: __dirname,
entry: {
    app: ['./src/index.jsx'] // app: ['./MY_FOLDER_INPUT/MY_FILE_INDEX.jsx']
},
output = {
    path: PATH.join(__dirname, '/MY_FOLDER_OUTPUT'),
    filename: 'index.js'
},
module: {
    rules: [
        {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
                loader: "babel-loader"
            }
        }
    ]
}
};

package.json. Add next scripts:

"scripts": 
{ 
    "build": "webpack-dev-server --mode development --open", 
    "prod_build": "webpack --mode production" 
}

It should works


I had the same problem last week and I noticed that there was a whitespace character in the beginning of the filename (" webpack.config.js") that is not visible in VS Code. Probably It was the real problem when I made the question.

Hope It helps

Tags:

Webpack 4