課程
/前端開(kāi)發(fā)
/前端工具
/webpack深入與實(shí)戰(zhàn)
image-webpack-loader 在webpack2中使用出錯(cuò)
2017-02-24
源自:webpack深入與實(shí)戰(zhàn) 4-7
正在回答
Configure optipng's optimizationLevel option in its own options ,這里是說(shuō)如果你要壓縮圖片,針對(duì)某一類型的,你需要單獨(dú)的放到他的options里,{
????optipng: {
????????optimizationLevel: xxx
????}
}
test:/\.(png|jpg|gif|svg)$/i,
? ? ? ? ? ? ? loaders: [
? ? ? ? ? ? ? ? ? 'url-loader?limit=1000&name=images/[name]-[hash:5].[ext]!image-webpack'
? ? ? ? ? ? ? ]
你們用的是mac或者 ubuntu么,在這兩個(gè)環(huán)境下要安裝libpng?
mac: brew install libpng
ubuntu:apt-get install libpng
慕桂英5446361
我是這樣配置的
{ ? ?test: /\.(png|jpg|gif|svg)$/i, ? ?use: ['url-loader?limit=1000&name=images/[name]-[hash:5].[ext]','image-webpack-loader']}
報(bào)錯(cuò)是這樣:
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
先安裝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' ???????} ?????] }
為何 會(huì)出現(xiàn)警告呢。。。。webpack2 ?按照 ?image-webpack-loader ?的寫(xiě)的 ? 那個(gè)大神幫忙看看
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!./~/._postcss-loader@1.3.3@postcss-loader?{}!./~/._less-loader@4.0.3@less-loader/dist!./src/components/layer/layer.less 6:192-226
?@ ./src/components/layer/layer.less
?@ ./src/components/layer/layer.js
?@ ./src/app.js
(Emitted value instead of an instance of Error) DEPRECATED. Configure optipng's optimizationLevel option in its own options. (optipng.optimizationLevel)
weibo_忽如一夜爆星辰_0
慕粉201919995
Chyrain
qbaty
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
?{
????????????????test:?/\.(png|jpg|gif|svg)$/i,
????????????????loaders:?[
????????????????????'url-loader?limit=4000&name=[name]-[hash:5].[ext]',
????????????????????'image-webpack-loader'
????????????????]
????????????}?
webpack2 不能將loader省略,應(yīng)完整寫(xiě)出: 'image-webpack-loader'
use:[
{
loader:'url-loader?limit=20000&name=assets/[name]-[hash:5].[ext]!image-webpack'
]
我自己換成了webpack2的配置如下:
test: /\.(png|jpg|gif|svg)$/i, ? ? ? ? ??
use: [
loader: 'url-loader', ? ? ? ? ? ? ? ? ? ??
options: {
name: 'assets/[name]-[hash:5].[ext]',
limit: 4000 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
},
'image-webpack-loader' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
] ? ? ? ? ? ? ? ? ? ? ??
SoooHy
慕粉1831401519
阿亮007 回復(fù) 慕粉1831401519
舉報(bào)
webpack實(shí)戰(zhàn)教程,用真實(shí)項(xiàng)目帶你探索 webpack 強(qiáng)大的功能
4 回答image-webpack-loard在wewebpack2中使用出錯(cuò)
5 回答image-webpack-loader按照官方文檔使用報(bào)錯(cuò)
2 回答安裝image-webpack-loader報(bào)錯(cuò)
9 回答image-webpack-loader img-loader報(bào)同樣的錯(cuò)
2 回答webpack使用loader 報(bào)錯(cuò)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-12-29
Configure optipng's optimizationLevel option in its own options ,這里是說(shuō)如果你要壓縮圖片,針對(duì)某一類型的,你需要單獨(dú)的放到他的options里,{
????optipng: {
????????optimizationLevel: xxx
????}
}
2017-08-04
test:/\.(png|jpg|gif|svg)$/i,
? ? ? ? ? ? ? loaders: [
? ? ? ? ? ? ? ? ? 'url-loader?limit=1000&name=images/[name]-[hash:5].[ext]!image-webpack'
? ? ? ? ? ? ? ]
2017-05-25
你們用的是mac或者 ubuntu么,在這兩個(gè)環(huán)境下要安裝libpng?
mac: brew install libpng
ubuntu:apt-get install libpng
2017-04-25
我是這樣配置的
{
? ?test: /\.(png|jpg|gif|svg)$/i,
? ?use: ['url-loader?limit=1000&name=images/[name]-[hash:5].[ext]','image-webpack-loader']
}
報(bào)錯(cuò)是這樣:
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
2017-04-10
先安裝img-loader : ?
然后在webpack.config.js中配置:
2017-04-07
為何 會(huì)出現(xiàn)警告呢。。。。webpack2 ?按照 ?image-webpack-loader ?的寫(xiě)的 ? 那個(gè)大神幫忙看看
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!./~/._postcss-loader@1.3.3@postcss-loader?{}!./~/._less-loader@4.0.3@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!./~/._postcss-loader@1.3.3@postcss-loader?{}!./~/._less-loader@4.0.3@less-loader/dist!./src/components/layer/layer.less 6:192-226
?@ ./src/components/layer/layer.less
?@ ./src/components/layer/layer.js
?@ ./src/app.js
2017-04-04
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
2017-03-19
?{
????????????????test:?/\.(png|jpg|gif|svg)$/i,
????????????????loaders:?[
????????????????????'url-loader?limit=4000&name=[name]-[hash:5].[ext]',
????????????????????'image-webpack-loader'
????????????????]
????????????}?
webpack2 不能將loader省略,應(yīng)完整寫(xiě)出: 'image-webpack-loader'
2017-02-25
use:[
{
loader:'url-loader?limit=20000&name=assets/[name]-[hash:5].[ext]!image-webpack'
}
]
2017-02-24
我自己換成了webpack2的配置如下:
{
test: /\.(png|jpg|gif|svg)$/i, ? ? ? ? ??
use: [
{
loader: 'url-loader', ? ? ? ? ? ? ? ? ? ??
options: {
name: 'assets/[name]-[hash:5].[ext]',
limit: 4000 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
}
},
'image-webpack-loader' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
] ? ? ? ? ? ? ? ? ? ? ??
}