Я работаю над проектом , который использовал babel версии 5, webpack версии 1 и ava версии 0.14.0.
После того, как я сделал некоторые обновления при запуске npm run build-example
Я получаю:
Ошибка сборки модуля (из ./node_modules/babel-loader/lib/index.js): Ошибка: найдено несколько файлов конфигурации. Удалите один:
- package. json
- pathto \ react-stars.babelr c
Вот мой старый пакет. json
После обновлений я использую babel версии 7.10, webpack версии 4.43 и ava версии 3.10.1. Вот обновленный package.json
{
"name": "react-rating-stars-component",
"version": "2.2.0",
"description": "Simple star rating component for your React projects.",
"main": "dist/react-stars.js",
"repository": "https://github.com/ertanhasani/react-stars",
"babel": {
"presets": [
"react",
"es2015"
]
},
"ava": {
"babel": {
"presets": [
"es2015",
"react"
]
},
"require": [
"babel-register"
]
},
"scripts": {
"build": "babel src --out-dir dist",
"dev": "babel src --out-dir dist --watch",
"build-example": "webpack -p --config webpack.production.config.js",
"dev-example": "webpack-dev-server . --hot --inline"
},
"keywords": [
"star",
"rating",
"react",
"stars",
"rating",
"component",
"raty",
"rate",
"reactjs",
"ratings"
],
"author": "Ertan Hasani",
"license": "ISC",
"devDependencies": {
"ava": "^3.10.1",
"@babel/cli": "^7.10.4",
"babel-loader": "^8.1.0",
"@babel/core": "^7.10.4",
"@babel/plugin-transform-object-assign": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-addons-test-utils": "^15.6.2",
"react-dom": "^16.13.1",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {}
}
Вот мой старый webpack.production.config. js
Вот обновленный webpack.production.config.js
:
'use strict';
var webpack = require('webpack')
module.exports = {
entry: ['./example/index.js'],
output: {
filename: './example/bundle.js',
pathinfo: true
},
module: {
rules: [{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['@babel/react', '@babel/preset-env']
}
}]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
],
optimization: {
minimize: false
}
};
Вот мой старый webpack.config.js
мой обновленный webpack.config.js
:
'use strict';
module.exports = {
entry: ['./example/index.js'],
debug: true,
devtool: 'inline-source-map',
output: {
filename: './example/bundle.js',
pathinfo: true
},
module: {
loaders: [{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['@babel/react', '@babel/preset-env']
}
}]
}
};
Я также обновил `.babelr c. файл:
Вот мой старый .babelrc
файл!
мой обновленный .babelrc
файл:
{
"presets": ["@babel/preset-env", "@babel/react"],
"plugins": [
"@babel/plugin-transform-object-assign"
]
}