2013-05-26 26 views
3

我有一個腳本標籤是這樣的:RequireJS使用錯誤的URL

<script src="https://ZZZ.s3.amazonaws.com/js/require-jquery.js?Signature=XXX&amp;Expires=1369597850&amp;AWSAccessKeyId=YYY" data-main="https://ZZZ.s3.amazonaws.com/js/snippet_create.js?Signature=XXX&amp;Expires=1369597850&amp;AWSAccessKeyId=YYY"></script> 

但資產無法加載,它看起來像它的覆蓋與本地網頁資源路徑:

Failed to load resource: the server responded with a status of 404 (NOT FOUND) http://localhost:8000/snippet_create.js?Signature=XXX&Expires=1369597850&AWSAccessKeyId=YYY 

這是所有坐在django-require,但它發生在客戶端,所以我不知道爲什麼。

我的build文件看起來像這樣(漂亮的樣板):

/** 
* Build profile for django-require. 
* 
* This supports all the normal configuration available to a r.js build profile. The only gotchas are: 
* 
* - 'baseUrl' will be overidden by django-require during the build process. 
* - 'appDir' will be overidden by django-require during the build process. 
* - 'dir' will be overidden by django-require during the build process. 
*/ 
({ 

    baseUrl: 'https://ZZZ.s3.amazonaws.com/js' 
    /* 
    * paths to use for modules 
    */ 
    paths: { 
     "util"  : "util", 
     "jquery" : "require-jquery", 
     "ace"  : "ace", 
     "bootstrap" : "bootstrap.min" 
    }, 

    /** 
    * shim in modules that do not follow amd specs 
    */ 
    shim: { 
     "bootstrap": { 
      deps: ["jquery"], 
      exports: "$.fn.popover" 
    } 
    /* 
    * List the modules that will be optimized. All their immediate and deep 
    * dependencies will be included in the module's file when the build is 
    * done. A minimum module entry is {name: "module_name"}. 
    */ 
    modules: [{ 
      name: "snippet_create", 
      exclude: ["jquery"] 
    }], 

    /* 
    * Allow CSS optimizations. Allowed values: 
    * - "standard": @import inlining, comment removal and line returns. 
    * Removing line returns may have problems in IE, depending on the type 
    * of CSS. 
    * - "standard.keepLines": Like "standard" but keeps line returns. 
    * - "none": Skip CSS optimizations. 
    * - "standard.keepComments": Keeps the file comments, but removes line returns. 
    * - "standard.keepComments.keepLines": Keeps the file comments and line returns. 
    */ 
    optimizeCss: "standard", 

    /* 
    * How to optimize all the JS files in the build output directory. 
    * Right now only the following values are supported: 
    * - "uglify": Uses UglifyJS to minify the code. 
    * - "uglify2": Uses UglifyJS2. 
    * - "closure": Uses Google's Closure Compiler in simple optimization 
    * mode to minify the code. Only available if REQUIRE_ENVIRONMENT is "rhino" (the default). 
    * - "none": No minification will be done. 
    */ 
    optimize: "uglify2", 

    /* 
    * By default, comments that have a license in them are preserved in the 
    * output. However, for a larger built files there could be a lot of 
    * comment files that may be better served by having a smaller comment 
    * at the top of the file that points to the list of all the licenses. 
    * This option will turn off the auto-preservation, but you will need 
    * work out how best to surface the license information. 
    */ 
    preserveLicenseComments: true, 

    /* 
    * The default behaviour is to optimize the build layers (the "modules" 
    * section of the config) and any other JS file in the directory. However, if 
    * the non-build layer JS files will not be loaded after a build, you can 
    * skip the optimization of those files, to speed up builds. Set this value 
    * to true if you want to skip optimizing those other non-build layer JS 
    * files. 
    */ 
    skipDirOptimize: false 



}) 

我不明白爲什麼requirejs使用了錯誤的網址,當它被送入一個不同的明確。

幫助?

回答

2

baseUrl必須是相對的。因爲構建需要過程試圖訪問光盤上的文件,並且不會通過HTTP下載它們。您可以使用絕對URL引用模塊,但它們不會包含在輸出中。

此外,使用數據主屬性時,不能使用查詢字符串參數。要了解在Chrome開發人員工具中查看正在進行的操作,您將看到正在請求的資源,這將有助於您瞭解正在發生的事情。

+0

謝謝!我想baseURL不是問題(因爲我還沒有運行構建腳本),但關於查詢字符串參數的事情扔給我。 –