YUI Compressor Minify all JS in a specific folder - javascript

is there a way to minify all the JS file into a specific folder and output it into another file path? because currently i'm using a single process like this:
java -jar yuicompressor-2.4.7.jar "C:\QG\Website\YUI\dev\jqueryMain.js" -o "C:\QG\Website\YUI\prod\jqueryMain.min.js"
im using Win 10

Related

How to Bundle javascript file without using npm or nodejs? [ Standalone javascript bundler ]

I am working on a project and I am not using any nodejs or npm package, But in the Production site, I want to upload the "bundled and minified javascript" file.
Is there any way to bundle a javascript file without using npm or nodejs?
update: I am using Apache as a web-server. It's a simple static website, but I have 5 JS files. I want to bundle them all in one just like how webpack does with the bundling of all files and combining them all in one with minification.
Thanks

compiling pug templates to single client side js file

I just started working with pug and am using it for a small single page app. I'm using templates that are compiled to javascript functions that I will use in my SPA to render HTML. Using the pug-cli, I am able to generate multiple .js files that each contain the desired template function. However, instead of compiling multiple javascript files, I'd like to merge all the functions in a simple 'template.js' file that I can then call from my client app. Here's the command I'm currently using
pug -c --name-after-file -w .\views\ -o .\public\
I've googled it, searched on Stackoverflow, and also found out that the pug API itself has the pug.compileFileClient that is meant to do this perhaps for an Express app. However, I couldn't find if this functionality is implemented in the pug-cli.
There is an npm package called puglatizer that takes a directory of pug templates and compiles it into single .js file that can be included in your html file and individual render functions can be called to produce the html.
It can be used both at the command line using a CLI or imported via require can called programmatically in your build process.
I ended up using the CLI version. Simply install the package globally using:
npm install puglatizer -g
Then run puglatizer -d path/to/templates -o /path/to/output/templates.js
This will compile all the templates in the path/to/templates folder to a templates.js file in /path/to/output.
Include the generated file in your html page via the script tag.
Then you can call the template in Javascript by invoking puglatizer.TemplateFileName({data:"myData"}) where TemplateFileName is the file name of on your pug templates in the path/to/templates directory.

How to bundle JavaScript files in PhpStorm

How to combine 2 or more JavaScript files in to a one file in PhpStorm (OR WebStorm).
I've searched and found just this result but it is not an answer:
Minifying JavaScript
I want something like this: Visual studio Bundler & Minifier plugin.
There's no built-in feature for that in IDE.
You can configure a grunt task inside IDE to concatenate files with https://github.com/gruntjs/grunt-contrib-concat
See also: Combine multiple JavaScript files into one JS file and
Combine and Minify Multiple CSS / JS Files

Grunt uglify - replace original file

I have an angular application that uses require.js to load all scripts. The application is deployed to the web server using Hudson CI. When the deploy job runs, I want to:
Minify all JavaScript files but preserve the original file names so that the require.js config file works out of the box.
Have an option to exclude specific JavaScript files while running uglify.
The JS files are distributed all across the application, which has an ontology similar to the following:
app/
common/
controllers/
factories/
services/
assets/
js/
Is there a way to do this?
you need grunt-contrib-uglify
for the excluding files requirement:
http://gruntjs.com/configuring-tasks#files

Compile js file with coffee file

Do you know if it is possible to build a js file (jquery for example) with another file that contains coffeescript? The end result is to obtain a single JS file.
Use a build tool like Grunt.
Compile and merge coffeescript files with grunt contrib coffee and then use a build task to merge the javascript files and compiled coffeescript files into a single file: http://gruntjs.com/sample-gruntfile
You may also take a look at grunt contrib uglify

Categories