webpack3.8.1 => webpack4.39.2
1、error:webpack is not a function
fix scripts/start.js
const compiler = createCompiler(webpack, config, appName, urls, useYarn);
=>
const compiler = createCompiler({ webpack, config, appName, urls, useYarn });
2、error: this.htmlWebpackPlugin.getHooks is not a function
fix config/webpack.config.*.js
new InterpolateHtmlPlugin(env.raw),
=>
new InterpolateHtmlPlugin(HtmlWebpackPlugin,env.raw),
3、弃用 ExtractTextPlugin =>为 mini-css-extract-plugin
{
test: /\.(css|less)$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
sourceMap: shouldUseSourceMap,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
{
loader: require.resolve('less-loader'),
options: {
modifyVars: antdtheme,
javascriptEnabled: true
},
},
]
},
4、error: Chunk.initial was removed. Use canBeInitial/isOnlyInitial() at Chunk.get initial
解决方法:升级 "webpack-manifest-plugin": "^1.3.2" 到 "webpack-manifest-plugin": "^2.0.4"
5、warning:Tapable.plugin is deprecated. Use new API on .hooks
instead
此警告信息指出某个loader或plugin使用了废弃的api,但不影响打包编译。
通过获取stracktrace来确定谁发出警告:
process.traceDeprecation = true;
原文地址:https://www.cnblogs.com/hideonbush/p/11415851.html
时间: 2024-10-05 03:10:23