Webpackconfig che non vuole saperne

di il
0 risposte

Webpackconfig che non vuole saperne

Buongiorno..ho questo webpackconfig.js 

import { resolve as _resolve } from 'path';  

    export const entry = {

   app: './src/testrx.js'

};

export const resolve = {

   extensions: ['', '.js', '.jsx']

};

export const output = {

   path: _resolve(__dirname, 'dev'),

   filename: 'main_bundle.js'

};

export const mode = 'development';

export const module = {

   rules: [

      {

         test: /\.(js)$/,

         include: _resolve(__dirname, 'src'),

         loader: 'babel-loader',

         options: {

            presets: ['@babel/preset-env']

         }

      }

   ]

};  

ma quando faccio il build mi da questo errore

[webpack-cli] Failed to load 'C:\PrjtestRSJX\webpack.config.js' config
[webpack-cli] ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and 'C:\PrjtestRSJX\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.      
   at file:///C:/PrjtestRSJX/webpack.config.js:9:19

Potete aiutarmi? cosa sbaglio?

Devi accedere o registrarti per scrivere nel forum
0 risposte