亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

image-webpack-loader 在webpack2中使用出錯

image-webpack-loader 在webpack2中使用出錯

正在回答

10 回答

Configure optipng's optimizationLevel option in its own options ,這里是說如果你要壓縮圖片,針對某一類型的,你需要單獨的放到他的options里,{

????optipng: {

????????optimizationLevel: xxx

????}

}

0 回復 有任何疑惑可以回復我~

test:/\.(png|jpg|gif|svg)$/i,

? ? ? ? ? ? ? loaders: [

? ? ? ? ? ? ? ? ? 'url-loader?limit=1000&name=images/[name]-[hash:5].[ext]!image-webpack'

? ? ? ? ? ? ? ]


1 回復 有任何疑惑可以回復我~

你們用的是mac或者 ubuntu么,在這兩個環境下要安裝libpng?

mac: brew install libpng

ubuntu:apt-get install libpng


1 回復 有任何疑惑可以回復我~
#1

慕桂英5446361

謝謝 是不是 沒有libpng 就不能正常運行。
2017-07-14 回復 有任何疑惑可以回復我~

我是這樣配置的

{
? ?test: /\.(png|jpg|gif|svg)$/i,
? ?use: ['url-loader?limit=1000&name=images/[name]-[hash:5].[ext]','image-webpack-loader']
}


報錯是這樣:

ERROR in ./images/ico_arrowB.png

Module build failed: TypeError: Cannot read property 'bypassOnDebug' of null

? ? at Object.module.exports (C:\Users\Administrator\Desktop\cal\node_modules\image-webpack-loader\index.js:30:26)

?@ ./~/css-loader!./~/autoprefixer-loader!./css/common.css 6:3955-3990

?@ ./css/common.css

?@ ./script/jquery-1.11.3.mini.js

?@ multi ./script/user_calendar.js ./script/common.js ./laydate/laydate.js ./script/sweetalert.min.js ./script/jquery.se

archableSelect.js ./script/jquery-1.11.3.mini.js


0 回復 有任何疑惑可以回復我~

先安裝img-loader : ?

npm?install?img-loader?--save-dev

然后在webpack.config.js中配置:

{
?????test:?/\.(png|jpg|gif|svg)$/i,
?????use:?[
???????{
???????loader:?'url-loader',
???????options:?{
?????????limit:?10000,
?????????name:?'assets/[name]-[hash:5].[ext]'
???????}
???????},
???????{
???????loader:?'img-loader'
???????}
?????]
}


1 回復 有任何疑惑可以回復我~

為何 會出現警告呢。。。。webpack2 ?按照 ?image-webpack-loader ?的寫的 ? 那個大神幫忙看看

WARNING in ./src/images/chosen.png

(Emitted value instead of an instance of Error) DEPRECATED. Configure gifsicle's interlaced option in its own options. (gifsicle.interlaced)

?@ ./~/.0.28.0@css-loader!./~/[email protected]@postcss-loader?{}!./~/[email protected]@less-loader/dist!./src/components/layer/layer.less 6:192-226

?@ ./src/components/layer/layer.less

?@ ./src/components/layer/layer.js

?@ ./src/app.js


WARNING in ./src/images/chosen.png

(Emitted value instead of an instance of Error) DEPRECATED. Configure optipng's optimizationLevel option in its own options. (optipng.optimizationLevel)

?@ ./~/.0.28.0@css-loader!./~/[email protected]@postcss-loader?{}!./~/[email protected]@less-loader/dist!./src/components/layer/layer.less 6:192-226

?@ ./src/components/layer/layer.less

?@ ./src/components/layer/layer.js

?@ ./src/app.js


0 回復 有任何疑惑可以回復我~
#1

weibo_忽如一夜爆星辰_0

我也遇到了,你可解決?
2017-06-15 回復 有任何疑惑可以回復我~
#2

慕粉201919995

我也碰到了這個報錯 不知道該怎么解決
2017-06-22 回復 有任何疑惑可以回復我~
#3

Chyrain

看錯誤提示!應該是在options里配置,把interlaced放到gifsicle里,optimizationLevel放到optipng里,類似這樣: { loader: 'image-webpack-loader', options: { optipng: { optimizationLevel: 7 }, gifsicle:{ interlaced: false }, pngquant: { quality: '65-90', speed: 4, }, mozjpeg: { quality: 65 } } }
2017-12-01 回復 有任何疑惑可以回復我~
#4

qbaty

Chyrain說的是對的
2017-12-29 回復 有任何疑惑可以回復我~
查看1條回復

loaders: [
?{
? ?test: /\.(gif|png|jpe?g|svg)$/i,
? ?loaders: [ ? ? ?'file-loader',
? ? ?{
? ? ? ?loader: 'image-webpack-loader',
? ? ? ?query: {
? ? ? ? ?progressive: true,
? ? ? ? ?optimizationLevel: 7,
? ? ? ? ?interlaced: false,
? ? ? ? ?pngquant: {
? ? ? ? ? ?quality: '65-90',
? ? ? ? ? ?speed: 4
? ? ? ? ?}
? ? ? ?}
? ? ?}
? ?]
?}
]
https://github.com/tcoopman/image-webpack-loader

0 回復 有任何疑惑可以回復我~

?{

????????????????test:?/\.(png|jpg|gif|svg)$/i,

????????????????loaders:?[

????????????????????'url-loader?limit=4000&name=[name]-[hash:5].[ext]',

????????????????????'image-webpack-loader'

????????????????]

????????????}?

webpack2 不能將loader省略,應完整寫出: 'image-webpack-loader'


0 回復 有任何疑惑可以回復我~

use:[

{

loader:'url-loader?limit=20000&name=assets/[name]-[hash:5].[ext]!image-webpack'

}

]


2 回復 有任何疑惑可以回復我~

我自己換成了webpack2的配置如下:

{

test: /\.(png|jpg|gif|svg)$/i, ? ? ? ? ??

use: [

{

loader: 'url-loader', ? ? ? ? ? ? ? ? ? ??

options: {

name: 'assets/[name]-[hash:5].[ext]',

limit: 4000 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

}

},

'image-webpack-loader' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

] ? ? ? ? ? ? ? ? ? ? ??

}


0 回復 有任何疑惑可以回復我~
#1

SoooHy

為什么我這么寫依然報錯= =
2017-03-17 回復 有任何疑惑可以回復我~
#2

慕粉1831401519

我寫的完整的'image-webpack-loader'也報錯,換成img-loader就沒問題
2017-03-31 回復 有任何疑惑可以回復我~
#3

阿亮007 回復 慕粉1831401519

我換成img-loader 也報錯
2017-04-04 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

image-webpack-loader 在webpack2中使用出錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號