1

I have created the environment variable (user and system) BROWSERSLIST_CONFIG and set it to C:\Program Files (x86)\Microsoft VS Code\bin\package.json.

However, when I run webpack and set debug to true I get empty targets:

@babel/preset-env: `DEBUG` option

Using targets:
{}

Even though my package.json has the following:

"browserslist":{
    "DEBUG": ["last 2 Firefox versions"],
    "PRODUCTION": ["> 2%", "last 2 versions", "ie >= 11"]
},

If I add the targets/browsers option directly into webpack.config it works fine but I have multiple projects and I want to share a central package.config.

Is there something missing in how I call babel-loader?

{
    test: /\.js$/,
    exclude: /node_modules/,
    use: {
        loader: 'babel-loader',
        options: {
            presets: [[nodeFolder + '@babel/preset-env', {
                targets: {
                  browsers: [
                    "last 2 Chrome versions"
                  ]
                }, "debug": true
              },
            ]],
        },
    },
},
rory
  • 1,490
  • 3
  • 22
  • 50

1 Answers1

1

Fixed. I added in the path to the config's directory as an option to the preset:

use: {
    loader: 'babel-loader',
    options: {
        presets: [[nodeFolder + '@babel/preset-env', { 
            "debug": true,
             "configPath": 'C:\\Program Files (x86)\\Microsoft VS Code\\bin\\'
          },
        ]],
    },
},
rory
  • 1,490
  • 3
  • 22
  • 50