Last active
December 23, 2024 22:42
-
-
Save nadyshalaby/5c37c6161a695933298192ccfc981ceb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g uglify-js clean-css-cli |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"filewatcher.commands": [ | |
{ | |
"match": "(?<!\\.min)\\.(js|css)$", | |
"isAsync": true, | |
"cmd": "minify ${file} > ${fileDirname}/${fileBasenameNoExt}.min${fileExtname}", | |
"event": "onFileChange" | |
} | |
] | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"filewatcher.commands": [ | |
{ | |
// npm install uglify-js -g | |
"match": "\\.js$", | |
"notMatch": "\\.min\\.js$", | |
"isAsync": true, | |
"cmd": "uglifyjs ${file} -o ${fileDirname}/${fileBasenameNoExt}.min.js -c -m --verbose", | |
"event": "onFileChange" | |
}, | |
{ | |
// npm install clean-css-cli -g | |
"match": "\\.css$", | |
"notMatch": "\\.min\\.css$", | |
"isAsync": true, | |
"cmd": "cleancss -o ${fileDirname}/${fileBasenameNoExt}.min.css ${file}", | |
"event": "onFileChange" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've recreated the VSCode settings file with the file watcher configuration. Now when you save any JS or CSS file in VSCode, it should automatically create or update the minified version. You can check the Output panel (View -> Output -> File Watcher) to see any errors or output from the minification process.