UglifyJS Exclude Folder from Minifying JS - javascript

I have a specific folder which contains 5 JavaScript files and I would like UglifyJS to ignore them all (i.e. not minify). I am aware of the exclude option, but not sure how to use it exactly in relation to the absolute path of the folder within the solution and how the format of the exclude string should be.
Thank you in advance.

Try using the pattern option
--pattern '**/*.js,!**/folder/*.js'

Related

concat typescript files in certain order after compilation

I would like achieve with gulp this:
compile ts to js, this is not problem
then concat js files in certain order, this is problem
I am creating angular application hence I need concat ts files in certain order.
gulp.src(paths.appTs) //src contains files in right order
.pipe(print())
.pipe(tsc(tsOptions))
.pipe(print()) //after compilation are files in bad order
.pipe(useref())
.pipe(concant("app.js"))
.pipe(gulp.dest(paths.dist + "/app"))
.pipe(print());
The best will be possible use gulp-useref
then concat js files in certain order, this is problem
I don't recommend using out / outFile (https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md) as manually ordering TS files can be a pain.
Highly recommend using modules e.g. --module commonjs and leverage something like webpack to build for the browser.
Order of files can be enforced by adding
///<reference path="relative/path/to/file.ts" />
At the top of your .ts files.
For more information, please see
https://www.typescriptlang.org/docs/handbook/namespaces.html#splitting-across-files

Replace filename with fingerprinted version using Grunt

assets.json maps the filenames:
{
"css\\global.css": "css\\global.a4b054fc.css",
"js\\js-common.js": "js\\js-common.d41d8cd9.js",
"js\\js-libs.js": "js\\js-libs.c3d17a06.js",
"js\\js-trace.js": "js\\js-trace.60465814.js",
"templates\\error.hbs": "templates\\error.6d003395.hbs"
}
During the build process (Grunt) I need to match the original file names (within a html file) and replace them with the fingerprinted version.
I've looked at a few packages however none seem to do what I'm looking for, any ideas?
Refer npm grunt-rekai which does what you need and if you would need more than available feature. You can add own tak after that using grunt-exec

file pattern exists check under a directory

In nodejs there is a file.exists. but it wouldn't navigate recursively through a directory. so what would be the best way to check if a file pattern exists under a directory/return the list using nodejs/javascript?
I don't need to read the file..I just need the match of files only.
You could use a module like glob for doing this kind of thing.

Exclude everything but Javascript files in RequireJS Optimizer

I am using RequireJS optimizer in a gulp recipe to compile and concatenate my Modules but redundant 3rd party library files like bower.json and *.nuspec files are being copied to my output directory.
I have successfully managed to exclude full directories using fileExclusionRegExp in the requirejs.optimize options object with the following expression:
/^\.|^styles$|^templates$|^tests$|^webdriver$/
However, I cannot figure out how to exclude everything but .js file extensions. I could use the following:
/^\.|.json$|.nuspec$|^styles$|^templates$|^tests$|^webdriver$/
to exclude specific extensions but if a new type were to appear later, I would have to notice and then change the regex. Also, the regex would probably become unruly and hard to maintain with time. I have tried to use the following expressions:
/^\.|!js$|^styles$|^templates$|^tests$|^webdriver$/
/^\.|!.js$|^styles$|^templates$|^tests$|^webdriver$/
/^\.|^.js$|^styles$|^templates$|^tests$|^webdriver$/
/^\.|[^.js$]|^styles$|^templates$|^tests$|^webdriver$/
/^\.|[^.js]$|^styles$|^templates$|^tests$|^webdriver$/
The results ranged from doing nothing (the first 3, to breaking the build, last 2) any help anyone could provide would be appreciated.
Thanks
Try this regex:
^\.|\.(json|nuspec)$|^(styles|templates|tests|webdriver)$

Node path prefixes for modules

This should be a very simple question. I think it might be as simple as just being the convention, but I would like to check as I have no idea if there is anything else behind it or what phrases to even search regarding it.
var hello = require('./hello');
hello.world();
Imagine the above code. The require path is prefixed by a ./ this is always present for files in the same folder. Why not just the file name?
Comparitively the common use
var http = require('http');
Is not prefixed by a ./ I am currently assuming this is due to the http file being a "native" module. Therefore would I be right in saying that anything without ./ is looking in the native Node namespace and anything with a ./ is looking for a local file?
Also would a file in a higher directory like in PHP it would be ../
In Node would it be .././ or ./../
Yeah, this is a simple convention used in node. Please see the module.require docs
And for what it's worth, you won't always be using require("./hello"). Sometimes you'll be using require("../../foo") or require("../").
Simply put,
You use a path for requiring files within your module
You use a string identifier for including other modules

Categories