我放棄了一口整齊的教程,現在只需使用NPM腳本https://www.npmjs.com/
權在package.json
文件,你可以使用SCSS,autoprefix它,醜化並縮小它和您的腳本,並控制它將輸出到哪些文件夾,例如生產文件夾。
這裏是package.json
{
"name": "Sample build",
"version": "1.0.0",
"description": "New build",
"author": "Author",
"license": "MIT",
"main": "index.html",
"scripts": {
"autoprefixer": "postcss -u autoprefixer -r production/css/*.css",
"scss": "node-sass --output-style expanded --indent-width 4 -o production/css development/scss",
"uglify": "uglifyjs development/js/*.js -m -o production/js/scripts.js",
"serve": "browser-sync start --server --files \"production/css/*.css, production/js/*.js\"",
"build:css": "npm run scss && npm run autoprefixer",
"build:js": "npm run uglify",
"build:all": "npm run build:css && npm run build:js",
"watch:css": "onchange \"development/scss\" -- npm run build:css",
"watch:js": "onchange \"development/js\" -- npm run build:js",
"watch:all": "npm-run-all -p serve watch:css watch:js",
"start": "npm run build:all && npm run watch:all"
},
"devDependencies": {
"node-sass": "^4.5.0",
"postcss-cli": "^3.0.0-beta",
"autoprefixer": "^6.7.6",
"browser-sync": "^2.18.8",
"npm-run-all": "^4.0.2",
"onchange": "^3.2.1",
"uglify-js": "^2.8.3"
}
}
和相應的文件結構設置一個樣本設置:
Project
|__ development
| |____ js
| |____ scss
|
|__ production
| |___ js
| |___ css
| |___ images
|
|_ index.html
|_ package.json
所有的開發者做的是運行npm install
然後npm start
大多數的WebPack模板做這(在技術上這是一個節點解決方案)。 JS的熱門替代品是即時更新,但實時更新CSS是即時可靠的。像[this](https://github.com/facebookincubator/create-react-app)和[this](https://github.com/vuejs-templates/webpack) – Matt
如果你只是在做HTML,CSS ,並且我會推薦brackets.io。它具有每次更改時更新的實時預覽功能,而且它也是開源的。 – RBCunhaDesign
插入'meta'標記[](https://www.w3schools.com/tags/att_meta_http_equiv.asp) – AvrilAlejandro