0

Below is my build configuration file: 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'
    }]
}

I am using "grunt-requirejs": "~0.4.2" as my build npm and Gruntfile requirejs configuration + r.js 2.1.16:

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

Whenever i am try to execute grunt requirejs it is throwing below error on my console:

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

Can you please help me out here and tell what i have missed in my configuration ?

Thanks & Regards

Ashwin Hegde
  • 1,733
  • 4
  • 19
  • 49

1 Answers1

0

You're using grunt.file.read which reads a file and returns the file's content as a string.

Use grunt.file.readJSON instead.

cbley
  • 4,538
  • 1
  • 17
  • 32
  • The above error is nothing to do with grunt.file.read or readJSON. I changed it but it did not worked. – Ashwin Hegde Feb 16 '15 at 09:50
  • You probably got a different error. Which one? Could you provide a _complete_ minimal example which exposes the error? Note, that the build.js has to be valid JSON when you use the readJSON function, ie. you have to double quote the property names. – cbley Feb 17 '15 at 07:45