r.js

Javascript regex to match a pattern but NOT match a regex literal (r.js optimizer and uglify issue)?

一笑奈何 提交于 2019-12-12 02:26:43
问题 I've got a Backbone application, organized into modules using Require.js. One of these modules contains a Handlebars helper, which has a method I use to pull a legal header off of all our HTML templates for each View. The header is contained in an HTML comment, so I use the following regex to strip it off: /<!--[\s\S]*?-->/g Now, when I optimize (concatenate/compile/minify) the application using r.js, I'm doing the same removal of HTML comments using the onBuildWrite() method of r.js:

$injector:modulerr after r.js optimization, but not before

半城伤御伤魂 提交于 2019-12-11 05:59:18
问题 I'm using require.js with r.js to optimize. Pre-optimization, I have: // MainCtrl.js define(function () { return ["$scope", function ($scope) { console.log($scope); }]; }); // main.js require.config({ shim: { angular: { exports: "angular", }, }, paths: { angular: "lib/angular.min", }, }); require(["angular", "MainCtrl"], function (ng, MainCtrl) { console.log(ng); var app = ng.module("myapp", []); app.controller("MainCtrl", MainCtrl); }); My HTML is very simple; it just has ng-app=myapp in

RequireJS optimization into multiple modules

♀尐吖头ヾ 提交于 2019-12-07 22:58:32
问题 I am trying to use RequireJS to modularize our JS into a few larger JS files so that dependencies can be loaded on-demand but without the heft of a large single-JS download when loading the page. As an example, with the JS files as: js/main.js js/views/category1/js1.js js/views/category1/js2.js js/views/category2/js1.js js/views/category2/js2.js Some parts of the application (e.g. everything in category1) are only used by certain types of users, and similarly with category2, so it doesn't

Getting 'Uncaught Error: Script error' for a declared dependency when using r.js

ⅰ亾dé卋堺 提交于 2019-12-07 06:20:08
问题 I couldn't find an answer for my issue on SO or Github, so I am posting this: I created a repo for this issue: https://github.com/saviomuc/requireJSMultiPage I tried to set up require.js for a multipage project. All is fine when I am running the page. But when I try to optimize the files with r.js I am getting this error: GET http://localhost:63342/requirejs/www-build/js/library.js 404 (Not Found) require.js:7 Uncaught Error: Script error for: library http://requirejs.org/docs/errors.html

Understanding r.js options w/grunt & backbone and relative paths

旧街凉风 提交于 2019-12-06 13:45:57
I'm trying to figure out how to use r.js. I keep getting errors thrown such a module path does not exist, or files getting dumped where they shouldn't be. I've got a single page application that is integrated with wordpress. I've adopted this backbone boilerplate for my general structure, although I've set things up quite different. My file structure is shown below. .Theme Folder ├── _assets | ├── _application | | ├── css | | ├── fonts | | ├── img | | ├── _js | | | ├── main.js //this is my require.js config file | | | ├── _app //here's where the boilerplate structure comes into play | | | ├──

Using r.js to package a SPA application that loads views using 'text'

余生颓废 提交于 2019-12-05 16:05:07
问题 I'm attempting to build a SPA application (requirejs, durandal 2, knockout) into a single main-build.js file using grunt, and I'm running into serious issues with the 'text' plugin that durandal is using to load my views. In dev, I'm successfully using 'text' to load views dynamically as per the standard way of building durandal apps. The difference is that I need to do some server side templating for the views and so they are actually being dynamically generated. With that in mind I'd like

Getting 'Uncaught Error: Script error' for a declared dependency when using r.js

百般思念 提交于 2019-12-05 08:34:30
I couldn't find an answer for my issue on SO or Github, so I am posting this: I created a repo for this issue: https://github.com/saviomuc/requireJSMultiPage I tried to set up require.js for a multipage project. All is fine when I am running the page. But when I try to optimize the files with r.js I am getting this error: GET http://localhost:63342/requirejs/www-build/js/library.js 404 (Not Found) require.js:7 Uncaught Error: Script error for: library http://requirejs.org/docs/errors.html#scripterror The setup is like this: js/app/app1.js js/app/app1jq.js js/lib/require.js js/lib/library.js

Way to bundle require.js source with main.js

安稳与你 提交于 2019-12-04 19:37:48
I have a unique situation where I need to have both the source and main.js in one file and for everything to initialize within that file, so no require calls on the page. Is this possible? If you want to include require.js with the main.js source, you can use this kind of command: node ../../r.js -o baseUrl=. paths.requireLib=../../require name=main include=requireLib out=main-built.js Since "require" is a reserved dependency name, you create a " requireLib " dependency and map it to the require.js file. Once that optimization is done, you can change the script tag to reference "main-built.js"

Disable uglyfying in r.js

∥☆過路亽.° 提交于 2019-12-03 05:54:47
I am looking for a way to prevent r.js (RequireJS' optimization script) from ugylyfying our JS-modules to maintain readability for debugging purposes. I expect the script (running on Node.js by the way) to have some command line option to be passed. Unfortunately, the documentation if this tool is rather poor. Pass optimize=none on the command line to r.js, or include optimize: "none" in your build script. eg: ({ baseUrl: ".", paths: { jquery: "some/other/jquery" }, name: "main", out: "main-built.js", optimize: "none" }) See http://requirejs.org/docs/optimization.html for more information. If

Most Efficient Multipage RequireJS and Almond setup

此生再无相见时 提交于 2019-11-28 03:02:27
I have multiple pages on a site using RequireJS, and most pages have unique functionality. All of them share a host of common modules (jQuery, Backbone, and more); all of them have their own unique modules, as well. I'm wondering what is the best way to optimize this code using r.js . I see a number of alternatives suggested by different parts of RequireJS's and Almond's documentation and examples -- so I came up with the following list of possibilities I see, and I'm asking which one is most recommended (or if there's another better way): Optimize a single JS file for the whole site , using