cmichaelgraham / aurelia-typescript

A starter kit for working with the Aurelia TypeScript type definitions
MIT License
144 stars 52 forks source link

Bootstrap Aurelia with single require() #36

Closed luboid closed 3 years ago

luboid commented 9 years ago

Hi,

Here is another way to bootstrap aurelia

        var origin = window.location.origin;
        var pathname = window.location.pathname;
        var baseUrl = origin + pathname.toLowerCase().replace("index-latest.html", "");
        // var baseUrl = "http://localhost:62960";
        require.config({
            baseUrl: baseUrl,
            paths: {
                aurelia: baseUrl + "/scripts/aurelia",
                webcomponentsjs: baseUrl + "/scripts/webcomponentsjs",
                views: baseUrl + "/views",
                underscore: baseUrl + "/scripts/underscore/underscore.min",
                three: baseUrl + "/scripts/three/three"
            },
            bundles: {
                'aurelia/aurelia-bundle-latest': ['aurelia-bootstrapper', 'aurelia-loader-default']
            },
            shim: {
                three: {
                    exports: "THREE"
                },
                underscore: {
                    exports: "_"
                },
                'aurelia-bootstrapper':{
                    deps: ['aurelia-loader-default']
                }
            }
        });

        require(["aurelia-bootstrapper"]);

or without any require([])

        var origin = window.location.origin;
        var pathname = window.location.pathname;
        var baseUrl = origin + pathname.toLowerCase().replace("index-latest.html", "");
        // var baseUrl = "http://localhost:62960";
        require.config({
            baseUrl: baseUrl,
            deps: ['aurelia-bootstrapper'],
            paths: {
                aurelia: baseUrl + "/scripts/aurelia",
                webcomponentsjs: baseUrl + "/scripts/webcomponentsjs",
                views: baseUrl + "/views",
                underscore: baseUrl + "/scripts/underscore/underscore.min",
                three: baseUrl + "/scripts/three/three"
            },
            bundles: {
                'aurelia/aurelia-bundle-latest': ['aurelia-bootstrapper', 'aurelia-loader-default']
            },
            shim: {
                three: {
                    exports: "THREE"
                },
                underscore: {
                    exports: "_"
                },
                'aurelia-bootstrapper': {
                    deps: ['aurelia-loader-default']
                }
            }
        });
npelletm commented 9 years ago

I spent time understanding why Aurelia do not start before find this post, thanks :+1: