Skip to content

Instantly share code, notes, and snippets.

@escapedcat
Last active May 16, 2018 09:39
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save escapedcat/5ff41e4b2b88e11d4f95 to your computer and use it in GitHub Desktop.
Save escapedcat/5ff41e4b2b88e11d4f95 to your computer and use it in GitHub Desktop.
npm scripts including node-sass and autoprefixer
{
"name": "foo",
"version": "1.0.0",
"description": "foo project",
"main": "index.js",
"scripts": {
"start": "npm run serve | npm run watch-css",
"serve": "./node_modules/.bin/http-server -p 8080",
"build-css": "./node_modules/node-sass/bin/node-sass app/sass/style.scss -o app/css/ && ./node_modules/postcss-cli/bin/postcss --use autoprefixer app/css/style.css -d app/css/",
"watch-css": "nodemon -e scss -x 'npm run build-css'"
},
"author": "",
"license": "ISC",
"dependencies": {
"autoprefixer": "6.1.2",
"node-sass": "3.4.2",
"postcss-cli": "2.3.2"
},
"devDependencies": {
"http-server": "^0.8.5"
}
}
@rsurjano
Copy link

is this snippet compatible with Windows?

@isvladxxe
Copy link

@rsurjano use mingw console.
mingw console from install git for win

@aronhoyer
Copy link

aronhoyer commented Mar 10, 2018

npm run watch:css returns an error for me.

Plugin Error: Cannot find module './public/css/main.css'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aronhoyer@1.0.0 build:css: `./node_modules/node-sass/bin/node-sass public/sass/main.sass -o public/css && ./node_modules/postcss-cli/bin/postcss --use autoprefixer ./public/css/main.css -d ./public/css/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aronhoyer@1.0.0 build:css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aronhoyer/.npm/_logs/2018-03-10T14_38_18_578Z-debug.log

package.json scripts look like this:

"scripts": {
    "start": "npm run serve | npm run watch:css",
    "build:css": "./node_modules/node-sass/bin/node-sass public/sass/main.sass -o public/css && ./node_modules/postcss-cli/bin/postcss --use autoprefixer ./public/css/main.css -d ./public/css/",
    "watch:css": "nodemon -e sass -x \"npm run build:css\""
}

@simonfranzen
Copy link

simonfranzen commented Mar 20, 2018

@aronhoyer I got working scripts:

"build-css": "./node_modules/node-sass/bin/node-sass public/sass/index.scss -o public/css && npx ./node_modules/postcss-cli/bin/postcss public/css/index.css  --use autoprefixer -d public/css",
"watch-css": "./node_modules/nodemon/bin/nodemon.js -e scss -x 'npm run build-css'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment