Hello evryone,
I'm trying to find a way to make the r.js not to copy all the files form my /lib/ directory except for (for example) jquery.js and require.js.
I'm using fileExclusionRegExp option to exclude all *.js files except for the above mentioned.
fileExclusionRegExp: '\/lib\/(?!jquery|require).*\.js'
But after the optimization, I can still see that other files have been copied over too.
Is there anything I'm doing wrong ? Or is the regex incorrect?
Thanks in advance
The problem you've run into is that you are trying to make fileExclusionRegExp match the entire path of a file, but r.js uses it only to test against the base name of files. You can infer this from the description of the option and its default value. The description says:
//When the optimizer copies files from the source location to the
//destination directory, it will skip directories and files that start
//with a ".".
The default value is:
/^\./
If this were to be tested against a full path, it would not be able to exclude files that start with a period if they are in a subdirectory. We also find confirmation of this behavior in this issue report.
If you have only one file named require.js and one file named jquery.js, then you can get by with this regexp:
fileExclusionRegExp: /^(?!jquery|require).*\.js$/
Otherwise, fileExclusionRegExp is not going to do it, and you should use a build step to clean your directory, as suggested by the author of RequireJS in the issue report I mention above.
Related
I would like to concatenate my .css and .scss files in a specific order.
For example, I'd like to be able to specify the first file in my build process and move to other directories when that is complete (1st .scss files then .css files). In the end, I'd like to have generated a single .css file
I'm just looking for some guidance on where to go and what to read (more specific to my situation) in order to figure this out. I've done a bit of research and haven't found a solution or someone who has tried to do that before.
I'm wondering is there a way to solve this problem:
I would like to copy all fonts from bower_components to .tmp/assets/fonts, but the problem is that some fonts are .svg, so if I do it in a regular way using this code:
gulp.task('copyBowerFonts', function(){
return gulp.src("bower_components/**/*.{ttf,woff,eof,svg}")
.pipe(gulp.dest(paths.tmpFonts));
});
... i will get all font files along with .svg files, so the mentioned peace of code will also copy images with .svg extension and put them into the .tmp/assets/fonts . So if i could say ok, copy everything from fonts/ within any folder to the desired location it would be great.
I will also use gulp-flatten to copy just files without their folder structure.
So, finally, is there an option like, or how could this work?:
gulp.src("bower_components/**/fonts/*.{ttf,woff,eof,svg}"
I assume that solution is simple, but I couldn't find it so far.
Thanks for the help. :)
The pattern you wrote should work for you.
Keep in mind that Gulp uses glob module:
* 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.
In the image below on the left in the folders you can see my /src Typescript (blue) compiled into my /dist (purple) Javascript using tsc.
You can see in the source file on the left that references a .ts module file that it isn't compiled into referencing a .js module file on the right.
Why not? How could the Javascript possibly run if tsc doesn't convert references?
Second question: I then tried manually changing the compiled reference from .ts to .js and running node dist/server.js but I get the error cannot find module tools/typescriptImport.js'. Why does node fail to find the module when it is correctly referenced (and you can see on the far right that it is a module)?
For starters, you have to remove the .ts extension from the import. TypeScript says that it treats it as a static string and won't change it.
Second, out of experience, I guess using a .d.ts file may solve your module not found error. I have solved many times by using this small hack. You can reference it using /// <reference path="tools/typeScriptImports.d.ts" />. Imagine .d.ts as the header file for TypeScript.
Lastly, try and make the path relative to the server.js file. So: ./tools/typeScriptImports.
You are not supposed to write extension .ts in import commands.
Corresponding documentation: http://www.typescriptlang.org/Handbook#modules-going-external
I am looking for a better glob pattern for usemin, i want to to find all .js files but exclude the .spec.js files. I have the following solution so far.
<script src="components/**/*(.js|!(*.spec.js|*.scss))"></script>
The solution i have at the moment requires me to keep adding file extensions to exclude them, else they get picked up, for example .html files.
I tried to make it only look for .js files and exclude the .spec.js from them but it does not seem to work.
Also adding a !components/**/*.spec.js as another script below does not seem to work.
This glob includes all *.js but not *.spec.js:
components/**/!(*.spec).js
I would like to use Webshim in a Symfony2 project.
So far, the webshim library is in mybundle/Resources/public/components/webshim...
The webshim library has a polyfiller.js that loads specified scripts from the ./shims directory. This is also clearly explained from the webshim docs:
The code inside of the polyfiller.js automatically detects the path to the script it is run from and assumes, that the shims folder is in the same directory. This means, you have to make sure, that either the shims folder is placed parallel to the code of the polyfiller.js or to configure the path using the basePath option.
I'm using other libraries and they all end in the /web/js or /web/css directories as they should do. They are combined and have names like "6464de0.js" and are perfectly accessible.
But, webshim tries to load scripts from the shims folder. This makes sense when you look at the docs.
This is an example of 404's in the console:
GET http://domain.dev/app_dev.php/js/shims/combos/1.js 404 (Not Found)
How can I make the webshim library work with assetic?
I have the same issue and here is what I did:
Put the 'shims' folder in the public folder of your desired bundle (eg. AcmeBundle/Resources/public/js/shims) then when you do assets:install using the console command it will be installed in the Symfony/web directory.
Then set the webshim option so that it points to that path:
webshim.setOptions('basePath', '/bundles/acme/js/shims/');