做者:robert 倉庫地址:gitee.com/dawwdadfrf/…css
最近在學習element的源碼,想着學習element的時候來順便把webpack,css,ts方面的知識也學一學,由於是第一次分享,過程當中可能存在着不少的不足之處。請你們多多指教。本項目適用於小夥伴入門,文章將持續更新vue
- 安裝node環境
- 安裝npm環境
- 建立build空文件
- 建立src空文件
- 建立.npmrc文件,文件內容以下
registry=https://registry.npm.taobao.org
disturl=https://npm.taobao.org/dist
sass_binary_site=https://npm.taobao.org/mirrors/node-sass
electron_mirror=https://npm.taobao.org/mirrors/electron/
PUPPETEER_DOWNLOAD_HOST=https://npm.taobao.org/mirrors
複製代碼
- npm install webpack-cli --save-dev
- npm install webpack --save-dev
console.log('123')
複製代碼
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, '../dist')
}
}
複製代碼
{
"name": "share-ui",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --config build/webpack.config.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
}
}
複製代碼
此時目錄結構中會多出一個dist目錄和在dist目錄下面多了bundle.jsnode
以上內容若有遺漏錯誤,歡迎留言 ✍️指出,一塊兒進步💪💪💪
若是以爲本文對你有幫助,🏀🏀留下你寶貴的 👍
下一篇:webpack啓動本地服務到加載vue文件