Skip to content

Commit 38b619a

Browse files
committed
Tweaking configuration so that we're now properly controlling the baseUrl to load compiled or not compiled files entirely. The flag is still manually set
1 parent 3555fa9 commit 38b619a

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ Optimization
3636
read - we're basically abusing it
3737
- ./node_modules/.bin/r.js -o app/config/build.js
3838
- temporarily added a path to js-built inside Twig
39-
- added more items to common.js beyond just jQuery
39+
- added more items to common.js beyond just jQuery
40+
- optimized a single page
41+
PPP common.js is still pointing to the "js" directory, not js-built!

app/config/build.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
({
22
mainConfigFile: '../../web/assets/js/common.js',
3-
appDir: '../../web/assets/js',
4-
baseUrl: './',
5-
dir: '../../web/assets/js-built',
3+
appDir: '../../web/assets',
4+
baseUrl: './js',
5+
dir: '../../web/assets-built',
6+
optimizeCss: "none",
67
modules: [
78
//First set up the common build layer.
89
{
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
<script src="{{ asset('assets/vendor/requirejs/require.js') }}"></script>
1+
{% set useCompiled = true %}
2+
{% set assetsPath = 'assets'~(useCompiled ? '-built') %}
3+
4+
<script src="{{ asset(assetsPath~'/vendor/requirejs/require.js') }}"></script>
25
<script>
3-
require(['{{ asset('assets/js/common.js') }}'], function (common) {
4-
//js/common sets the baseUrl to be js/ so
5-
//can just ask for 'app/main1' here instead
6-
//of 'js/app/main1'
6+
7+
// let the baseUrl be dynamic so we can use the compiled assets when needed
8+
requirejs.config({
9+
baseUrl: '{{ assetsPath }}/js'
10+
});
11+
12+
require(['common'], function (common) {
713
require(['{{ data_main }}']);
814
});
9-
</script>
15+
</script>

web/assets/js/common.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//except for 'app' ones, which are in a sibling
77
//directory.
88
requirejs.config({
9-
baseUrl: 'assets/js',
109
paths: {
1110
app: 'app',
1211
domReady: '../vendor/requirejs-domready/domReady',

0 commit comments

Comments
 (0)