我正在尝试创建一个 grunt 任务来使用 requirejs 和闭包编译器作为优化器来构建一个 javascript 项目。我正在使用 grunt-contrib-requirejs 插件。
https://www.npmjs.org/package/grunt-contrib-requirejs
虽然我没有明确设置闭包编译器,但这里是配置和错误:
配置:
requirejs:
compile:
options:
sourceMap: true
baseUrl: "client"
mainConfigFile: "main.js"
name: "main.js"
out: "build/main.js"
optimize: "closure"
#generateSourceMaps: true
closure:
CompilerOptions: {},
CompilationLevel: 'SIMPLE_OPTIMIZATIONS'
loggingLevel: 'WARNING'
错误:
C:\Users\Project>grunt requirejs
Running "requirejs:compile" (requirejs) task
{ [Error: Error: optimizer with name of "closure" not found for this environment
at Object.optimize.js (C:\Users\Project\node_modules\requirejs\bin\r.js:24771:27)
]
originalError: [Error: optimizer with name of "closure" not found for this env
ironment] }
Closure 是用 java 编写的,我的项目是用 nodejs 编写的,我不确定如何正确设置它。