3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Make Modular app with require.js

3
Posted at

require.config({
		paths:{
			jquery: "lib/jquery-1.8.0",
			underscore:"lib/underscore",
			backbone:"lib/backbone",
			todo: "models/todo",
			todo_view: "views/todo_view"
		},
		// 依存関係、外部に出す変数を設定する
		//exportsはnode.jsのmodule.exportsと同じ考え.
		shim:{
			// "backbone" refer to paths["backbone"]
			"backbone":{
				// set dependency module.
				deps:["underscore","jquery"],
				// It's same as exports = Backbone
				exports: "Backbone"
			},
			// exports _.
			"underscore":{
				exports: "_"
			}
		}
});

<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<script data-main="app/config" src="app/lib/require.js"></script>
		<script>
			// call main.js.
			require(["main"]);
		</script>
		</meta>
	</head>
	<body>
	</body>
</html>
main.js
define(["jquery","underscore","backbone"],function($,_,Backbone){

	// write some great code!


});

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?