4

r.js を必要な方法で動作させるのに問題があります。

次の問題があります: 2 つのドメイン (例: foo.de と bar.de) と異なる環境があります。実行している環境とドメインに応じて、元のサーバーから別のファイルをロードする必要があります。私の最初の解決策はこれでした:

// channelDomain and environmentPath get defined above this script
require.config({
  paths: {
    'fooscript': channelDomain+environmentPath
  }
}

最適化されていないブラウザーでこれをテストすると、正常に動作しますが、ナイトリー ビルドには次のような問題がありました。

[Error: Error: The config in mainConfigFile /absolute/path/app/public/js/main.js 
cannot be used because it cannot be evaluated correctly while running in the 
optimizer. Try only using a config that is also valid JSON, or do not use 
mainConfigFile and instead copy the config values needed into a build file or 
command line arguments given to the optimizer.
Source error from parsing: /absolute/path/app/public/js/main.js: ReferenceError:
channelDomain is not defined

いろいろやってみましたが、アイデアが尽きてしまいました。ビルドファイルで empty: を実行しようとしましたが、それも機能しませんでした。誰かが私を正しい方向に向けることができれば幸いです。

4

1 に答える 1