Skip to content

Instantly share code, notes, and snippets.

@rxaviers
Last active August 29, 2015 13:58
Show Gist options
  • Save rxaviers/10190528 to your computer and use it in GitHub Desktop.
Save rxaviers/10190528 to your computer and use it in GitHub Desktop.
require.js question regarding config path names
.
├── bower_components/
│   ├── jquery/
│   │       └── ...
│   ├── jquery-ui/
│   │   └── ui/
│   │       ├── accordion.js
│   │       ├── autocomplete.js
│   │       ├── button.js
│   │       ├── core.js
│   │       ├── datepicker.js
│   │       └── ...
│   └── ...
├── index.html
└── main.js
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<script data-main="main.js" src="bower_components/requirejs/require.js"></script>
</body>
</html>
require.config({
paths: {
jquery: "./bower_components/jquery/dist/jquery",
myui: "./bower_components/jquery-ui/ui"
}
});
require([
"myui/datepicker"
], function( datepicker ) {
console.log( "datepicker", datepicker );
}, function() {
console.log( "failed" );
});
require.config({
paths: {
jquery: "./bower_components/jquery/dist/jquery",
ui: "./bower_components/jquery-ui/ui"
}
});
require([
"ui/datepicker"
], function( datepicker ) {
console.log( "datepicker", datepicker );
}, function() {
console.log( "failed" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment