I have the following folder structure in my Meteor project.
> .meteor
>public
> client (dir)
>> foo.html &
>> foo.js
>> bar (dir: client/bar)
>>> bar.html &
>>> bar.js
> server
>> baz.js
I want to format all JS files inside of client directory
npx prettier --write 'client/**/*.js'
only formats files like bar.js. In reality I have up to 5 levels deep folders, and they need to be formatted too.
npx prettier --write 'client/**'
Works, but affects html (handlebar) files, I want to avoid that.
Any ideas? I can't find anything in the documentation, a part from manually adding an ignore to all .html files but that's an overkill.
Add a .prettierignore file to your project root to ignore handlebars files, e. g.:
*.handlebars
You can add the following config to avoid handlebars (.hbs) formatting
"[handlebars]": {
"editor.formatOnSave": false,
"editor.formatOnPaste": false
}
Related
I have multiple minified files in multiple folder in a single folder for minified js.
I wish to create single js file from all of minified js.
Now I am using type command to concatenate all files like
type .\\v2\\dist\\js\\*.js >> .\\build\\a.min.js && type .\\v2\\dist\\js\\config\\*.js >> .\\build\\a.min.js && ...
Like wise I need to append all recursive folders.
Is there any clean way to do it.
Please don't suggest using Gulp or Grunt as we are already in process of removing them & using Webpack. Any code using webpack or using npm or simple command line is welcome.
If on Windows, you can use command line like below (refer to #dbenham's answer):
for /r "c:\javascripts" %F in (*.js) do #type "%F" >>concatenated.js
If on Linux or Mac, you can use find:
find ./v2/dist/js/ -name '*.js' -exec cat {} \; > ./build/a.min.js
I am using Gulp to build a deployable build for an application. I would like to cache-bust all of my .js and .css files so that when a new build is deployed, users will need to retrieve the new "cache-busted" files. For example, if an app.js file is stored in the browser's cache, I would like to have the ref to app.js in my index.html look something like this:
<script src="app/js/app.js?v=1.2"></script>
and so on for all relevant files I would like to cache bust.
Some other questions related to this problem I have:
1) How can I tell that these files are actually getting cache busted properly?
2) Is there a better way to approach this?
Here is what I am trying so far:
//compile index.html, app, vendor
gulp.task('compile-dist', function(){
var revAll = new RevAll();
gulp.src('../../backend-angular-seed/app/**')
.pipe(gulp.dest('../dist/app'));
gulp.src('../../backend-angular-seed/vendor/**')
.pipe(gulp.dest('../dist/vendor'));
gulp.src('../index.html')
.pipe(gulp.dest('../dist/'));
})
This code takes all of the code from my app/ directory (which is a result of my compiled code from my master/ directory) and builds a dist/ directory with all of my js, css, and vendor files.
After this build I have a dist/ directory that looks like this:
/dist
/css
|_app.css
/img
/js
|_ app.js
|_ base.js
/vendor
index.html
I have tried using a few different methods on modifying this dist directory to effectively have it bust the cache. I tried using gulp-cachebust as well as gulp-rev-all, but I believe both of these tools are a bit overkill for what I am trying to do.
Ideally, through Gulp, I would like to go into the index.html file made from the Gulp build, and modify all of my script tags to append the query string of "?v=1.0" on the end of all files I would like to cache bust per deploy build.
Any answers/suggestions would be greatly appreciated. Thanks so much!!!
If appending query string is all you want then i recommend using gulp-cache-bust.
var cachebust = require('gulp-cache-bust');
gulp.src('./dist/index.html')
.pipe(cachebust({
type: 'timestamp'
}))
.pipe(gulp.dest('./dist'));
Here is the turorial for it: https://www.npmjs.com/package/gulp-cache-bust
I've been attempting to implement a build solution using NPM scripts as opposed to Gulp/Grunt/etc as outlined here: http://substack.net/task_automation_with_npm_run and here: http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/. However, I'm struggling to integrate a clean and sensible approach for managing numerous Jade files in the build process.
The Jade CLI supports passing it a directory and outputting all of the deeply nested compiled Jade files. This is great, however, this completely flattens the folder structure. I'd ideally like to have Jade output the results whilst maintaining the directory structure. What's the best way to go about this?
Example folder structure:
package.json
src/
foo.jade
bar/
baz.jade
qux.jade
Running jade src -o build outputs:
package.json
build/
foo.html
baz.hmtl
qux.html
src/
Instead of:
package.json
build/
foo.html
bar/
baz.html
qux.html
src/
Not sure how I missed this but for anyone who should happen upon this in the future, the -H flag is your friend.
ex: jade src -H -o build
ref: https://github.com/jadejs/jade-cli/blob/master/index.js#L36
I have the following directory structure on a windows machine:
.gitignore
WebUserApp/
lib/
angular/
angular-ui-router/
typings/
.gitignore and WebUserApp are at the same level and under the WebUserApp is a lib direcotry. The lib directory contains three folders and I want to ignore the sending of the angular and angular-ui-router folders.
I tried the following .gitignore and it did not work:
# Ignore
WebUserApp/lib/angular
WebUserApp/lib/angular-ui-router
I tried this .gitignore and it worked:
# Ignore
/angular
/angular-ui-router
Can someone explain to me why the first version of .gitignore does not work
I think
someFolder/
ignores all folders named someFolder independent of the level in the tree, as long as it is below the current level.
You actually might want to try:
# Ignore
/WebUserApp/lib/angular/
/WebUserApp/lib/angular-ui-router/
Then you should be able to reference an relative path.
A slash at the end of the path such as
/WebUserApp/lib/angular/
git will just ignore folders named like that, but no files or symbolic links.
Try this
angular/
angular-ui-router/
It must be work fine.
When I try to do build with steal/buildjs of Javascript MVC, envJS silently fail to compress and check JavaScript files for errors.
I read documentation for envJS and found there that if in some case you try to build empty .js files envJS will fail.
Obviously it is in my case, and later I founded some of empty .js files.
I need a way to add checking for empty .js and .ejs files before build.
What would be the most efficient way to do check for empty .js and .ejs when running steal/buildjs?
I would use find:
find . -type f \( -name *.js -o -name *.ejs \) -size 0 -print
Change -print to -delete when you're sure.