webpack helloworld

1、下載nodejs,並且安裝

2、安裝webpack npm install webpack -g 3、查看webpack版本

4、隨意新建一個文件夾在其中放入

index.html

<html>

    <head>

        <meta charset="utf-8">

    </head>

    <body>

        <script type="text/javascript" src="./bundle/main.js" charset="utf-8">

    </script>

    </body>

</html>

 

main.js

document.write("It works.");

 

webpack.config.js

module.exports = { mode: 'development' };

 

我的目錄結構

5、在剛剛新建的文件夾下,在新建一個名爲bundle的文件夾。然後在剛剛新建的文件夾下執行命令 webpack ./main.js -o ./bundle

5、完成以上操作後會在 bundle 文件夾下生成一個 main.js

 

webpack-cli版本的helloworld

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章