-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixed-mod.html
More file actions
113 lines (102 loc) · 6.25 KB
/
mixed-mod.html
File metadata and controls
113 lines (102 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>RequireJS</title>
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper"></div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1>Simple (Modded) + Free Style + Lazy Load</h1>
<p>The simple implimentation of <a href="mixed.html">this page</a> was modified to make it buildable with <b>r.js</b></p>
<p>This page still uses lazy loading though.</p>
<div class="module-container"></div>
<h3>Configuration:</h3>
<pre><code class="language-javascript">
requirejs.config({
paths: {
"Block": 'mixed/block',
"jquery": "../../node_modules/jquery/dist/jquery",
"bootstrap": "../../node_modules/bootstrap/dist/js/bootstrap",
"prism": "../../node_modules/prismjs/prism",
"prism-remove-whitespace": "../../node_modules/prismjs/plugins/normalize-whitespace/prism-normalize-whitespace",
},
// shims are required for those packages which
// do not define() things in AMD format inside them.
// Eg. Bootstrap, Backbone, Underscore etc.
// Just for demo. Shimming makes sense when you have to return (export something) or bundle the modules,
// otherwise you can directly use the Non-AMD modules (only for lazy-loading) as well
shim: {
"bootstrap": {
deps: ["jquery"],
exports: "$", // useless here, useful for lodash or Underscore where you can export the window._ as "_"
},
"prism": {
deps: [],
exports: "window", // IMPORTANT: Without exports the shims are not created as there is no return.
},
"prism-remove-whitespace": {
deps: ["prism"],
exports: "window", // IMPORTANT: Remove this and check with enforceDefine: true.
},
},
map: {
'*': {
// To solve absolute path issue with rjs
// Without this map the r.js confuses base path to "C:\"
"/node_modules": "../../node_modules",
}
},
// Giving CSS and Text Loader plugins as package instead of map
// solves a lot of build issue (absolute path, internal dependencies, module-id generation)
// Refer: https://github.com/requirejs/r.js/issues/289
packages: [{
name: 'css',
location: '../../node_modules/require-css/',
main: 'css.min'
}, {
name: 'text',
location: '../../node_modules/text/',
main: 'text'
}],
// Enabling this a great way to check for correct shims
// When enabling, give this file in define as well
// enforceDefine: true,
// This is for bundling thing into seperate bundles
// bundles: {
// "prism-with-plugins": ["prism", "prism-remove-whitespace"],
// }
});
require([
"prism-remove-whitespace", // This automatically loads prism due to shim.
"css!/node_modules/prismjs/themes/prism-coy",
"css!../stylesheets/simple-sidebar",
"css!/node_modules/bootstrap/dist/css/bootstrap.min",
'mixed/child',
'mixed/sidebar/initSidebar',
], function() {
Prism.highlightAll(); // Known bug for prism: https://github.com/PrismJS/prism/issues/903
});
</code></pre>
<a href="#menu-toggle" class="btn btn-default" id="menu-toggle">Toggle Menu</a>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
<script src="node_modules/requirejs/require.js" data-main="public/app/app-mixed-modded"></script>
</body>
</html>