Я мог бы поклясться, что однажды увидел что-то, что package.json
может быть модульным. По сути, я хочу разбить определенные узлы файла json на дочерние файлы json (аналогично тому, как вы можете это сделать с помощью .Net web.configs). Я действительно просто хочу почистить / сделать обслуживаемым файл пакета. Например:
До
package.json
{
"name": "example.ui",
"version": "1.0.0",
"description": "Front-end React application",
"license": "UNLICENSED",
"scripts": {
"start": "webpack-dev-server --mode=development --hot --inline --config webpack.config.development.js",
"build": "webpack --bail -p --config webpack.config.production.js",
"test": "jest --coverage --coverageDirectory=output/coverage/jest --watchAll"
},
"jest": {
"coverageReporters": [
"text",
"html"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mockServer__/fileMock.js",
"\\.(css|less)$": "identity-obj-proxy",
"MockServer/NavigationData": "<rootDir>/mockServer/data/navigation.json",
"Config/api": "<rootDir>/src/config/api",
"Config/environment": "<rootDir>/src/config/environment",
"Config/constants": "<rootDir>/src/config/constants"
}
},
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"compression-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.0.4",
"css-loader": "^3.2.0",
"file-loader": "^4.2.0",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.9.0",
"webpack": "^4.39.2",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-dev-server": "^3.8.0"
},
"dependencies": {
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
}
}
После
package.json
{
"name": "example.ui",
"version": "1.0.0",
"description": "Front-end React application",
"license": "UNLICENSED",
"scripts": {
"start": "webpack-dev-server --mode=development --hot --inline --config webpack.config.development.js",
"build": "webpack --bail -p --config webpack.config.production.js",
"test": "jest --coverage --coverageDirectory=output/coverage/jest --watchAll"
},
"jest": "./package.jest.json",
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"compression-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.0.4",
"css-loader": "^3.2.0",
"file-loader": "^4.2.0",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.9.0",
"webpack": "^4.39.2",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-dev-server": "^3.8.0"
},
"dependencies": {
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
}
}
package.jest.json
{
"coverageReporters": [
"text",
"html"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mockServer__/fileMock.js",
"\\.(css|less)$": "identity-obj-proxy",
"MockServer/NavigationData": "<rootDir>/mockServer/data/navigation.json",
"Config/api": "<rootDir>/src/config/api",
"Config/environment": "<rootDir>/src/config/environment",
"Config/constants": "<rootDir>/src/config/constants"
}
}