Skip to content

Commit

Permalink
Resolve plugins and loaders
Browse files Browse the repository at this point in the history
In one of my projects I started to get errors saying that `babel-loader` was not found etc. I could solve this locally by resolving them with `require.resolve`
  • Loading branch information
alexandernanberg authored Apr 12, 2019
1 parent 83dbeba commit bf9d034
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ function webpackConfig(dir, additionalConfig) {
var babelOpts = { cacheDirectory: true };
if (!haveBabelrc(dir)) {
babelOpts.presets = [
['@babel/preset-env', { targets: { node: getBabelTarget(envConfig) } }]
[require.resolve('@babel/preset-env'), { targets: { node: getBabelTarget(envConfig) } }]
];

babelOpts.plugins = [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-object-rest-spread'
require.resolve('@babel/plugin-proposal-class-properties'),
require.resolve('@babel/plugin-transform-object-assign'),
require.resolve('@babel/plugin-proposal-object-rest-spread')
];
}

Expand Down Expand Up @@ -87,7 +87,7 @@ function webpackConfig(dir, additionalConfig) {
`(node_modules|bower_components|${testFilePattern})`
),
use: {
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: babelOpts
}
}
Expand Down

0 comments on commit bf9d034

Please sign in to comment.