Building with Grunt and Requirejs -


i creating grunt task building javascript project requirejs using grunt-contrib-requirejs

https://github.com/gruntjs/grunt-contrib-requirejs

here config:

requirejs:       compile:         options:           #appdir: './'           baseurl: "client"           mainconfigfile: "client/main.js"           name: "main"           out: "build/main.js"           wrap:             start: ""             end: "" 

the main.js file requires 2 other files inside subdirectories. althrough task not throw errors, resulting built file not run browser. files seem concatenated since require calls still exist in built file. expect js files called require substitute require calls, , optimized. how can achieve that?

ps: config above written in coffeescript.

if want compiled javascript file not contain , require() or define() calls can use amdclean npm package , simple add options object:

onmodulebundlecomplete: function (data) {   var fs = require('fs'),     amdclean = require('amdclean'),     outputfile = data.path;   fs.writefilesync(outputfile, amdclean.clean({     'filepath': outputfile   })); } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -