Skip to content

Instantly share code, notes, and snippets.

@watert
Last active August 29, 2015 14:07
Show Gist options
  • Save watert/d7a42e5461f485ec90b5 to your computer and use it in GitHub Desktop.
Save watert/d7a42e5461f485ec90b5 to your computer and use it in GitHub Desktop.
require config with bower
###
Gruntfile example for requirejs optimizing and less files watching
###
module.exports = (grunt) ->
out = (path)-> "../public-dist/#{path}"
grunt.initConfig
requirejs:
options:
mainConfigFile: "../public/require-config.js"
baseUrl: "../public"
optimize:"none"
# preserveLicenseComments: no
# generateSourceMaps:true
"base": options:
include: ["js/app/base","bootstrap"]
out: out("js/app/base.js")
"analyze/main": options:
name:"js/main"
include: [
"momentCn"
"moment"
"js/app/baseRoute"
"js/app/globalNav"
"js/views/globalQuery"
"js/views/query.sources"
"js/routes/overview"
"js/routes/trend"
"js/routes/roi"
"js/routes/tracking"
]
exclude: ["js/app/base","js/app/charts"]
out: out("js/analyze/main.js")
"analyze/charts": options:
include: [
"js/app/charts"
]
exclude: ["js/main"]
out: out("js/analyze/charts.js")
uglify:
options:
preserveComments:"some"
dist:
files:
"../public-dist/js/base.pack.min.js":[
"../public/bower_components/requirejs/require.js"
# "../public/require-config.js"
"../public-dist/js/app/base.js"
]
watch:
scripts:
files: ["../public/less/*"],
tasks: ["less"]
less:
dev:
options: paths: ["../public/less"]
files:
"../public/css/main.css": "../public/less/main.less"
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks "grunt-contrib-requirejs"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.registerTask "default", ["requirejs","uglify"]
require.config({
baseUrl:"public/",
shim:{
"backbone":["underscore"],
"jquery-bbq-deparam":["jquery"],
"bootstrap":["jquery"],
"momentCn":["moment"]
},
paths:{
backbone: "bower_components/backbone/backbone",
underscore: "bower_components/underscore/underscore",
jquery: "bower_components/jquery/dist/jquery.min",
"jquery-bbq-deparam": "bower_components/jquery-bbq-deparam/jquery-deparam",
marked: "bower_components/marked/lib/marked",
bootstrap:"bower_components/bootstrap/dist/js/bootstrap.min",
highcharts:"bower_components/highcharts/highcharts-all",
moment:"bower_components/moment/min/moment.min",
momentCn:"bower_components/moment/min/locale-zh-cn",
history:"bower_components/history.js/scripts/bundled/html4+html5/jquery.history"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment