我通过 grunt 使用 requirejs 优化器(r.js),这是我的 requirejs 配置:
requirejs.config
baseUrl: '/scripts'
locale: window.localStorage.getItem('locale') || null
...
问题是 grunt r.js 插件 ( https://github.com/gruntjs/grunt-contrib-requirejs ) 每次我尝试在我的 requirejs 配置中使用一个变量时都会抛出一个错误。
The main config file 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.
您是否设法同时使用变量作为语言环境和 r.js?