Warning 'missing babel configuration' even if .babelrc exist
smollweide opened this issue · 3 comments
smollweide commented
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
webpack.config.js
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CommonConfigWebpackPlugin = require('common-config-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
plugins: [
// Cleans the dist folder before the build starts
new CleanWebpackPlugin(['dist']),
// Multi threading babel loader configuration with caching for .js and .jsx files
// Multi threading typescript loader configuration with caching for .ts and .tsx files
// SCSS Configuration for .css .module.css and .scss .module.scss files
// File loader configuration for .woff and .woff2 files
// File loader configuration for .gif .jpg .jpeg .png and .svg files
// https://github.com/namics/webpack-config-plugins/
new CommonConfigWebpackPlugin(),
// Generate a base html file and injects all generated css and js files
new HtmlWebpackPlugin(),
],
};
.babelrc
module.exports = {
presets: [
[
require.resolve('@babel/preset-env'),
{
useBuiltIns: 'entry'
},
]
],
};
Prints warning:
Couldn't find an appropriate babel configuration file in the current directory.
Please check if the name of the file is correct and if it's in the correct directory.
For further information please check the documentation: https://babeljs.io/docs/en/babelrc.html
Expected behavior
.babelrc detected and used
Minimal reproduction of the problem with instructions
execute the following in a new directory:
npx @namics/frontend-defaults-cli@alpha --presetTs
and afterwards:
npm start
Environment
common-config-webpack-plugin version: 1.2.1
clean-webpack-plugin version: 1.0.0
html-webpack-plugin version: 3.2.0
- Node version: 8.10.0
- Platform: Mac
smollweide commented
Issue happens because of the babel function findRelativeConfig
.
It loops the packageData.directories.
packageData.directories
includes all parent directories except the cwd
.
Because of this the babel config file could not be found.
A workaround could be to push the cwd to the packageData.directories
array:
resolveBabelConfigFilePath(contextPath, environmentName) {
const packageData = findPackageData(contextPath);
packageData.directories.push(packageData.filepath);
const resolvedFilePath = findRelativeConfig(packageData, environmentName);
...
degiorgioo commented
Hi @smollweide I will check that. Thanks for your time. 👍
smollweide commented
Hi @degiorgioo,
okay because I already debugged the code and the solution above is not enough (findRelativeConfig ignore babel.config.js) I will create a PR for it.