I have a folder structure like this
ProjectX
.......|_____node_modules
.......|_____src
.......|_____build
.......|_____app
.......|_____libraries
I have written a glob pattern in grunt browserify something like this
src:['**/*.js','!node_modules','!build'],
dest:'build/build.js'
What i want from above code is, all .js files in my project should be browserified except the .js files in 'node_modules' and 'build' folder.
But what actually is happening is still the files from node_modules and build folder are browserified in my 'build/build.js' destination.
And i do not want to specify folder names of the .js file i require. I do not want to do something like this
['src/**/*.js' ... etc]
How can i solve this problem?
Related
I'm trying to configure a VSCode's setting that define a list of directories to exclude from a glob pattern.
Here is the default setting: {node_modules,doc,docs,.bundle,vendor}/**.
I would like to be able to exclude the directory node_modules excepts the following subfolders: animate.css and bootstrap.
I tried this {node_modules/!(animate.css|bootstrap),doc,docs,.bundle,vendor}/** but looks like the whole node_modules directory is not excluded anymore...
Thank you for any help!
Gulp: see below as an example
How to copy files ending with .html in a directory and its subdirectories?
How to copy files that not ending with .js in a directory and its subdirectories.
--dirA
--dirB
--b.html
--b.js
--dirC
--c.html
--index.html
Like jacmoe answered, if you need to get specific files in gulp, use that kind of syntax:
'/directory/*.fileextension' //Get all files in directory with .extension
'!/directory*.fileextension' //Ignore files with .extension
'/directory/**/*.fileextension' //Get all files in directory AND all subdirectories with .extension
And remember that gulp paths support arrays so you can write something like that:
['!/directory/**/*.js', '/directory/**/*'] //Get all files except .js files
Or if needed only specific files:
['/directory/**/*.html'] //Get all .html files
If I am not totally mistaken:
gulp.task('copyHTML', function() {
return gulp.src('directory/**/*.html')
.pipe(gulp.dest('copied/html'));
});
That code will copy any file ending in .html in any directory beneath the directory directory.
I am new to gulp.
I have a directory in /src which I want to move to /dist.
My directory looks like this with a depth of more than 1.
folder1
- folder2
-folder4
-folder5
-folder6
-folder7
-folder8
-folder10
-folder9
- folder3
I have declared src path as /src/folder1/* in gulp file and it has moved only folder1,folder2,folder3 to the destination path.folder2 and folder3 are empty folders which is perfectly fine.
I have declared src path as /src/folder/** in gulp file and it has moved all the folders as expected to the destination path.And while I was going through all the folders in destination path after running gulpfile, it crashed with segmentation11.What is the reason for this?
And what is the actual method to move all the folders of above structure in gulp?
This is the behavior of node-glob which gulp uses under the hood. From their readme:
* Matches 0 or more characters in a single path portion
..
** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does
not crawl symlinked directories.
* will match everything in the same directory.
** will match everything recursively (subdirectories).
The segmentation fault is most likely due to a flaw in your script.
I have the following file hierarchy:
scripts
someConfigFile.js
anotherConfigFile.js
someModuleDirectory
someModule.js
anotherModuleDirectory
anotherModule.js
subDirectory
thirdModule.js
I want to match all the files in the module directories, but excude the config files contained in the scripts directory itself, using Glob:
var glob = require('glob');
console.log(glob.sync(unknownGlobPattern));
Required output (unordered):
[
'someModuleDirectory/someModule.js',
'anotherModuleDirectory/anotherModule.js',
'anotherModuleDirectory/subDirectory/thirdModule.js'
]
The following glob should work:
['./scripts/**/*', '!./scripts/*']
First part will include all files in all subdirectories. Second part will exclude files in starting directory.
I want to Gulp Copy Multiple Files
gulp.task('copy', function(){
gulp.src(
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/jquery/dist/jquery.min.js',
'bower_components/jquery.stellar/src/jquery.stellar.js',
'bower_components/jquery-waypoints/waypoints.js',
'bower_components/jquery-easing-original/jquery.easing.1.3.js')
.pipe(gulp.dest('public/assets/js'));
});
To copy my files from my bower_components directory to my assets directory, but it is only working with the first line (bootstrap.js), all others are ignored.
I wouldn't like to pipe every single file to the destination directory.
How would I go about to do this?
regards,
George
P.S.
I am using it just for devel. In production I would concatenate and minify them before I deploy them. Nonetheless I believe that the task is clear, I want the bower_components to show up my public folder. I think that it is a little bit tedious to have all the files on the bower_components folder, only to copy them into your public directory. Is there any other best practice to use the bower component files?
Try to add [], like this:
gulp.src([
'file1',
'file2',
'file3'
])
.pipe(gulp.dest('public/assets/js'));