gpt4 book ai didi

javascript - Webpack 2 : WARNING in . png、.svg、.. 已弃用。在它自己的选项中配置 optipng 的 optimizationLevel 选项。 (optipng.optimizationLevel)

转载 作者:数据小太阳 更新时间:2023-10-29 03:58:21 24 4
gpt4 key购买 nike

这个警告在运行 webpack 时打印了大约 20 次——它处理和打包都很好,但这是什么意思?我该如何摆脱它?

不幸的是,谷歌搜索几乎没有帮助。

这是我的 webpack 配置:

const ExtractTextPlugin = require("extract-text-webpack-plugin");

var webpack = require("webpack");

module.exports = {
entry: {
dashboard: './js/main.js',
vendor: ["fixed-data-table","react","react-dom","jquery", "bootstrap", "vis",],
},
output: { path: "../public", filename: 'bundle.js' },

plugins: [
new webpack.optimize.CommonsChunkPlugin({name: "vendor", filename: "static/vendor.bundle.js"}),
new ExtractTextPlugin("/static/[name].css"),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
],

module: {
loaders: [
{
test: /.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
'es2015', 'react', 'stage-0',
],

}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader'}),
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=~/.local/share/Trash/[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false', {
loader: 'image-webpack-loader',
}
],

},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=~/.local/share/Trash/[name].[ext]'
}
]
},
};

警告示例(有很多!)

WARNING in ./~/vis/dist/img/network/addNodeIcon.png
DEPRECATED. Configure gifsicle's interlaced option in it's own options. (gifsicle.interlaced)
@ ./~/css-loader!./~/vis/dist/vis.min.css 6:12847-12887
@ ./~/vis/dist/vis.min.css

WARNING in ./~/bootstrap/dist/fonts/glyphicons-halflings-regular.svg
DEPRECATED. Configure gifsicle's interlaced option in it's own options. (gifsicle.interlaced)
@ ./~/css-loader!./~/bootstrap/dist/css/bootstrap.min.css 6:3700-3752
@ ./~/bootstrap/dist/css/bootstrap.min.css

最佳答案

您现在需要为特定的优化器指定您的选项。所以以前的 webpack 1.x 加载器配置是这样的;

loaders: [
'file-loader?name=assets/[name].[ext]',
'image-webpack-loader?progressive=true&optimizationLevel=7&interlaced=true'
]

成为

      use: [
{
loader: 'file-loader',
options: {
query: {
name:'assets/[name].[ext]'
}
}
},
{
loader: 'image-webpack-loader',
options: {
query: {
mozjpeg: {
progressive: true,
},
gifsicle: {
interlaced: true,
},
optipng: {
optimizationLevel: 7,
}
}
}
}]

注意选项对象,其中嵌入了查询。

https://webpack.js.org/guides/migrating/和deltones 在这个问题上的评论; https://github.com/tcoopman/image-webpack-loader/issues/68#issuecomment-275848595

关于javascript - Webpack 2 : WARNING in . png、.svg、.. 已弃用。在它自己的选项中配置 optipng 的 optimizationLevel 选项。 (optipng.optimizationLevel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42206190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com