one webpack study demo question

來源:互聯網
上載者:User

標籤:alt   update   follow   img   loader   教程   style   參考   記錄   

學習webpak,跟著官方小白教程,遇到了css資源載入的小問題,記錄下來,以供參考查閱。

  webpack小白學習教程:http://webpack.github.io/docs/tutorials/getting-started/

問題出在了“CSS檔案載入這一步”,即 THE FIRST LOADER。

按照教程中所示,添加了style.css檔案,同時更新了entry.js檔案。

1 require("!style!css!./style.css"); // add2 document.write(require("./content.js"));

運行命令“webpack ./entry.js bundle.js”,並沒有得到想要的結果,出現錯誤如下。

查看錯誤提示,沒有解析‘style‘。但是在這個操作之前,已經通過npm成功安裝style-loader 包的。最後還有一句提示,很重要啊。

You need to specify ‘style-loader‘ instead of ‘style‘.

???把style替換成style-loader。期初我對這個提示是忽視的,通過幾次安裝卸載style-loader和css-loader,無果後。才注意到這個提示。

不如,修改entry.js中的style、css試一下。

require("!style-loader!css-loader!./style.css"); // update follow error tipdocument.write(require("./content.js"));

到底可不可以呢?從新recompile,結果是通過了。就這樣通過了。

洋洋洒洒寫這麼多,我到底想說什麼呢?

多看錯誤提示,注重錯誤提示,認真分析錯誤提示!

BREAKING CHANGE: It‘s no longer allowed to omit the ‘-loader‘ suffix when using loaders. 是不是瞎?

 

one webpack study demo question

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.