本文介绍了带有 node-sass 和 autoprefixer 的 npm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 node-sass 将我所有的 Sass 文件编译为 master.css.这很有效,但现在我想添加前缀.我只想使用 npm,不要使用 Gulp 或 Grunt.
I use node-sass to compile all my Sass files to a master.css.This works well but now I want to add prefixes. I would like to use only the npm, no Gulp or Grunt.
这里是我的 package.json 文件:
Here my package.json file:
{
"name": "xxxxxx.com",
"version": "1.0.0",
"description": "",
"watches": {
"sass": "src/scss/**"
},
"scripts": {
"sass": "node-sass src/scss/master.scss -o dist/css/ --style compressed",
"prefix": "postcss --use autoprefixer dist/css/master.css -d dist/css/master.css",
"dev": "rerun-script"
},
"author": "Jan",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^6.3.1",
"browserify": "^13.0.0",
"clean-css": "^3.4.9",
"node-sass": "^3.4.2",
"postcss-cli": "^2.5.0",
"rerun-script": "^0.6.0",
"uglifyjs": "^2.4.10"
}
}
我没有让它运行.我使用 autoprefixer 和 postcss-cli.模块已本地安装在项目目录中.我认为我的脚本"部分是错误的.看起来怎么样?
I do not get it to run. I use autoprefixer and postcss-cli. The modules have been installed locally in the project directory. I think my "script" part is false.How would that look right?
推荐答案
{
"name": "npm-node-sass",
"version": "0.0.1",
"devDependencies": {
"autoprefixer": "^6.3.3",
"browserify": "^13.0.0",
"cssnano": "^3.5.2",
"jshint": "^2.9.1",
"node-sass": "^3.4.2",
"postcss": "^5.0.16",
"postcss-cli": "^2.5.1",
"watch": "^0.17.1"
},
"scripts": {
"prebuild:css": "node-sass --include-path scss src/sass/styles.scss public/css/styles.css",
"build:css": "postcss --use autoprefixer -b 'last 2 versions' < public/css/styles.css | postcss --use cssnano > public/css/styles.min.css",
"lint": "jshint src/js/*.js",
"build:js": "browserify src/js/main.js > public/js/bundle.js",
"build": "npm run build:css && npm run build:js",
"prebuild:js": "npm run lint",
"build:watch": "watch 'npm run build' src/*"
}
}
你需要 postcss 和 postcss-cli 作为 devDependency.
You need postcss and postcss-cli as a devDependency.
这篇关于带有 node-sass 和 autoprefixer 的 npm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!