Webpack 簡單配置Vue

1.初始化

  1. npm init 初始化項目,會生成package.json. 此時項目就擁有裝有的node_modules運行環境。css

  2. 安裝相應的包 npm i webpack vue vue-loader, 並根據提示安裝需求的依賴包。如css-loadervue-template-compliervue

    vue沒法在瀏覽器中直接運行,將vue組件掛載到js,而後經過webpack將js、css、圖片等全部資源進行打包。node

2.新建組件

3.新建index.js文件掛載vue組件

4.新建webpack.config.js

5.因爲webpack原生只支持js打包的,超過原生的其餘資源,須要在webpack.config.js中進行聲明rules

6.編輯package.json

"build": "webpack --config webpack.config.js"
複製代碼

7. .npm run build就會開始打包

相關文章
相關標籤/搜索