一 webpack 初識(shí)

DEMO

初始化

  mkdir webpack-test
  cd webpack-test
  npm init
  npm install webpack  --save-dev

創(chuàng)建 hello.js hello.css

hello.js

// require('style-loader!css-loader!./hello.css')
require('./hello.css')

function hello(str) {
    alert(str);
}

hello('hello world')
hello.css

html, body {
    background-color: red;
}

執(zhí)行webpack生成命令

 // webpack hello.js -o ./dist/hello_bundle.js --watch
 webpack hello.js -o ./dist/hello_bundle.js --module-bind 'css=style-loader!css-loader' --watch

看效果,創(chuàng)建一個(gè)index.html

<!DOCTYPE html>
<html>
<head>
    <title>webpack-test</title>
</head>
<body>
    <script type="text/javascript" src="./dist/hello_bundle.js"></script>
</body>
</html>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 失眠到凌晨。 光怪陸離的夢(mèng),奇奇怪怪的心情。 坐在辦公桌前又矯情的覺得支撐不住想要逃避了。
    Anges閱讀 227評(píng)論 0 0
  • 人活著本身就是一個(gè)矛盾體,會(huì)遇到很多參差不齊的,五花八門的,你無法解決但是就是困擾你的問題。問題的產(chǎn)生是你在這個(gè)世...
    應(yīng)小楓子閱讀 294評(píng)論 0 1
  • 詩(shī)歌難教,這是一線語(yǔ)文老師的共識(shí),尤其是現(xiàn)代詩(shī)。 幸好,中招考試不考現(xiàn)代詩(shī)。初中語(yǔ)文教材中的古代詩(shī)歌大家都耳熟能詳...
    今夜有風(fēng)3閱讀 891評(píng)論 2 15
  • 1 問題 項(xiàng)目中需要?jiǎng)討B(tài)改變頁(yè)面的 favicon,icon 文件存儲(chǔ)在阿里云(OSS)上。改變 favicon ...
    唯泥Bernie閱讀 1,463評(píng)論 0 0
  • 今天讀得書很溫暖,也很糟心,《新家庭如何塑造人》?;橐鰧?shí)在是太不容易了,特別是我們中國(guó)式的婚姻,你嫁的或取的是對(duì)方...
    一溪風(fēng)月閱讀 334評(píng)論 1 6

友情鏈接更多精彩內(nèi)容