0

下面是我的构建配置文件: 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

你能帮我看看我的配置中遗漏了什么吗?

感谢和问候

4

1 回答 1

0

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

改为使用grunt.file.readJSON

于 2015-02-16T09:21:45.963 回答