错误:使用r.js / grunt-requirejs缺少“out”或“dir”配置值

时间:2015-02-13 11:21:11

标签: r.js grunt-contrib-requirejs grunt-requirejs

以下是我的构建配置文件:build.js

{
    appDir: '../src',
    baseUrl: 'libs',
    paths: {
        app: 'js'
    },
    dir: '../prod',
    out:"../js/main-built.js",
    fileExclusionRegExp: /.less$/,
    optimize: "uglify2",
    optimizeCss: "standard",
    modules: [{
        name: '../js/main'
    }]
}

我正在使用“grunt-requirejs”:“~0.4.2”作为我的构建npm和Gruntfile requirejs配置+ r.js 2.1.16:

requirejs: {
    std: {
        options: grunt.file.read('config/build.js')
    }
}

每当我尝试执行grunt requirejs时,它会在我的控制台上抛出以下错误:

Error: Error: Missing either an "out" or "dir" config value. If using "appDir" for a full project optimization, use "dir". If you want to optimize to one file, use "out".
    at Function.build.createConfig (d:\app\node_modules\grunt-requirejs\node_modules\requirejs\bin\r.js:27717:19)
I want to consolidate some of the JS files like jquery and its plugins etc. into 1 file and i am using AMD pattern similar to project https://github.com/hegdeashwin/Protocore

你能帮帮我,告诉我在配置中遗漏了什么吗?

谢谢&此致

1 个答案:

答案 0 :(得分:0)

您正在使用grunt.file.read读取文件并将文件的内容作为字符串返回。

改为使用grunt.file.readJSON