Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update to latest require.js, document pragmasOnSave and has build opt…
…ions, flesh out http build example to send down just one script, have html test page.
- Loading branch information
Showing
9 changed files
with
141 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
<h1>One script via RequireJS optimizer</h1> | ||
|
||
<p><strong>Be sure to start up the server: node httpBuild.js</strong></p> | ||
|
||
<p>Demonstrates how to use the RequireJS optimizer to only load | ||
one script in the page using Node as the server to serve the optimized | ||
script. Using the "excludeShallow" build config option inside httpBuild.js | ||
allows debugging one script separate from the rest of the optimized file.</p> | ||
|
||
<p>See httpBuild.js in the same directory as this file for more information.</p> | ||
|
||
<hr> | ||
|
||
<!-- Successful load will print something after the hr tag --> | ||
|
||
<!-- httpBuild.js will return optimized content no matter what the URL | ||
is below. For deployment, replace this script tag to one that | ||
loads main-built.js, or whatever the config.out name value is | ||
inside httpBuild.js --> | ||
<script src="http://127.0.0.1:4304/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
//Set the baseUrl for scripts, for use | ||
//if individually debuggin files via | ||
//excludeShallow in httpBuild.js | ||
require.config({ | ||
baseUrl: 'scripts' | ||
}); | ||
|
||
require(['one', 'two'], function (one, two) { | ||
var html = "<b>Success!</b> One's name is: " + one.name + | ||
", two's name is: " + two.name + | ||
", three's name is: " + two.threeName, | ||
node = document.createElement('div'); | ||
|
||
node.innerHTML = html; | ||
|
||
document.getElementsByTagName('body')[0].appendChild(node); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
define({ | ||
name: 'one' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
define(function () { | ||
return { | ||
name: 'three' | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(function (require) { | ||
var three = require('three'); | ||
return { | ||
name: 'two', | ||
threeName: three.name | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
var cs = require('coffee-script'), | ||
requirejs = require('requirejs'); | ||
|
||
requirejs({ | ||
baseUrl: 'scripts', | ||
nodeRequire: require | ||
}, | ||
['./coffee/foo', 'bar'], | ||
function (foo, bar) { | ||
console.log('bar.data: ' + bar.data); | ||
console.log('foo.name: ' + foo.name); | ||
} | ||
); | ||
requirejs.config({ | ||
baseUrl: 'scripts', | ||
nodeRequire: require | ||
}); | ||
|
||
requirejs(['./coffee/foo', 'bar'], | ||
function ( foo, bar) { | ||
console.log('bar.data: ' + bar.data); | ||
console.log('foo.name: ' + foo.name); | ||
}); |