DEV Community

Ricardo Sanchez
Ricardo Sanchez

Posted on

Need help setting up a basic CSS & JS build using NPM scripts

Hi,

I need your help, I want to setup a very basic npm set of scripts to compile and minify Sass and JS ES6+ for personal projects.

So far my Google search only gives me old posts and convoluted builds that, at least for me, are hard to follow and refactor for my basic needs. For example most of the posts or video tutorials use uglify which is deprecated and don't work with modules, so I'm using Terser instead.

This is what I have so far:

"scripts": {
    "devserver": "live-server --open=/dist/",
    "sass": "node-sass scss/ -o dist/css/ -w",
    "terser": "terser js/index.js -c -m -o dist/js/index.js",
    "watch:sass": "onchange scss/*.scss -- npm run sass",
    "watch:js": "onchange js/*.js -- npm run terser",
    "start": "npm-run-all --parallel devserver watch:*"
},
"devDependencies": {
    "node-sass": "^4.14.1",
    "npm-run-all": "^4.1.5",
    "terser": "^5.1.0"
}

Any help, pointers and suggestions will be much appreciated.

Top comments (1)

Collapse
 
nardove profile image
Ricardo Sanchez

After banging my head to get this working I found parceljs it just works