我有一个项目,它使用 Babel 来执行所有与浏览器列表相关的选项。我在构建时收到警告:
> warn Replace Autoprefixer browsers option to Browserslist config. > Use browserslist key in package.json or .browserslistrc file. > > Using browsers option can cause errors. Browserslist config can be > used for Babel, Autoprefixer, postcss-normalize and other tools. > > If you really need to use option, rename it to overrideBrowserslist. > > Learn more at: https://github.com/browserslist/browserslist#readme > https://twitter.com/browserslist
互联网上有很多这个问题的例子,但是,对我来说,我的 package.json 中没有“autoprefixer”、“browsers”或“browserslist”。Gatsby 默认使用 Babel,它使用
{
"browserslist": [">0.25%", "not dead"]
}
在它的 package.json 中,但我的项目在任何地方都没有。
我的 package.json 依赖项供参考:
"dependencies": {
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.6.0",
"@loadable/component": "^5.15.0",
"@mui/material": "^5.0.6",
"@nivo/bar": "^0.61.1",
"@nivo/pie": "^0.61.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
"@react-pdf/renderer": "^2.0.21",
"@storybook/addon-docs": "^6.1.10",
"apollo-cache-inmemory": "^1.6.2",
"apollo-client": "^2.6.3",
"apollo-link": "^1.2.12",
"apollo-link-context": "^1.0.18",
"apollo-link-error": "^1.1.11",
"apollo-link-http": "^1.5.15",
"assert": "^2.0.0",
"auth0-js": "^9.18.0",
"axios": "^0.24.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"date-fns": "^1.30.1",
"file-saver": "^2.0.2",
"focus-visible": "^4.1.5",
"formik": "^2.2.9",
"gatsby": "^4.2.0",
"gatsby-image": "^3.11.0",
"gatsby-plugin-advanced-sitemap": "^2.0.0",
"gatsby-plugin-catch-links": "^4.2.0",
"gatsby-plugin-env-variables": "^2.1.0",
"gatsby-plugin-force-trailing-slashes": "^1.0.4",
"gatsby-plugin-gatsby-cloud": "^4.2.0",
"gatsby-plugin-google-tagmanager": "^4.2.0",
"gatsby-plugin-image": "^2.2.0",
"gatsby-plugin-react-axe": "^0.5.0",
"gatsby-plugin-react-helmet": "^5.2.0",
"gatsby-plugin-react-svg": "^3.1.0",
"gatsby-plugin-robots-txt": "^1.5.0",
"gatsby-plugin-sass": "^5.2.0",
"gatsby-plugin-sharp": "^4.2.0",
"gatsby-source-datocms": "^3.0.11",
"gatsby-source-filesystem": "^4.2.0",
"gatsby-transformer-sharp": "^4.1.0",
"graphql-tag": "^2.10.1",
"js-cookie": "^3.0.1",
"lodash": "^4.17.15",
"logrocket": "^2.1.2",
"node-sass": "^6.0.1",
"path-browserify": "^1.0.1",
"postcss": "^8.4.4",
"process": "^0.11.10",
"prop-types": "^15.7.2",
"pure-react-carousel": "^1.27.8",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-apollo": "^3.1.5",
"react-awesome-slider": "^4.1.0",
"react-csv-downloader": "^2.7.0",
"react-dom": "^17.0.2",
"react-google-recaptcha-v3": "^1.9.5",
"react-helmet": "^5.2.1",
"react-html-parser": "^2.0.2",
"react-inclusive-sortable-table": "^1.1.0",
"react-modal": "^3.9.1",
"react-outside-click-handler": "^1.3.0",
"react-player": "^2.9.0",
"react-scroll": "^1.7.12",
"react-share": "^4.4.0",
"react-storage-hooks": "^4.0.1",
"react-textarea-autosize": "^8.3.3",
"react-use-form-state": "^0.13.2",
"searchkit": "^2.3.1-alpha.9",
"sharp": "^0.29.2",
"slugify": "^1.6.3",
"stopword": "^1.0.11",
"stream-browserify": "^3.0.0",
"swr": "^1.1.0",
"tiny-async-pool": "^1.0.4",
"trunc-html": "^1.1.2",
"unfetch": "^4.1.0",
"webpack": "^5.64.2",
"yup": "^0.32.11",
"zxcvbn": "^4.4.2"
}
和我的 package.json devDependencies:
"devDependencies": {
"@babel/core": "^7.12.7",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-transform-classes": "^7.16.0",
"@babel/plugin-transform-regenerator": "^7.12.1",
"@bumped-inc/gatsby-plugin-optional-chaining": "^1.0.0",
"@cypress/code-coverage": "^3.9.11",
"@loadable/babel-plugin": "^5.13.2",
"@storybook/addon-a11y": "^6.1.10",
"@storybook/addon-essentials": "^6.1.10",
"@storybook/addon-knobs": "^6.1.10",
"@storybook/addon-links": "^6.1.10",
"@storybook/addon-storyshots": "^6.1.10",
"@storybook/react": "6.1.10",
"@testing-library/cypress": "^5.0.2",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^9.3.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.3.1",
"babel-loader": "^8.2.1",
"babel-plugin-macros": "^3.1.0",
"babel-preset-env": "^1.7.0",
"babel-preset-gatsby": "^2.4.0",
"chalk": "^4.1.2",
"cypress": "^8.7.0",
"cypress-graphql-mock": "^0.5.0-alpha.4",
"dlv": "^1.1.3",
"eslint": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^4.3.0",
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.26",
"husky": "^7.0.4",
"identity-obj-proxy": "^3.0.0",
"is-ci-cli": "^2.0.0",
"jest": "^27.3.1",
"jest-runner-eslint": "^1.0.0",
"jest-runner-sasslint": "^0.1.3",
"jest-watch-typeahead": "^1.0.0",
"lint-staged": "^12.0.2",
"mocha": "^8.2.0",
"mochawesome": "^6.1.1",
"mochawesome-merge": "^4.2.0",
"mochawesome-report-generator": "^5.1.0",
"neat-csv": "^5.1.0",
"plop": "^2.7.1",
"prettier": "^2.5.0",
"react-test-renderer": "^17.0.2",
"sass-lint": "^1.13.1",
"start-server-and-test": "^1.10.6"
}