Last active
December 28, 2015 19:09
-
-
Save Haraldson/7547952 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root | |
www | |
assets | |
js | |
my-app | |
app.js | |
lib | |
init.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) | |
{ | |
grunt.initConfig( | |
{ | |
pkg: grunt.file.readJSON('package.json'), | |
watch: { | |
css: { | |
files: ['www/assets/css/sass/**/*.scss'], | |
tasks: ['sass', 'autoprefixer', 'imageEmbed'] | |
} | |
}, | |
sass: { | |
dist: { | |
files: { | |
'www/assets/css/admin-interface.css': 'www/assets/css/sass/admin-interface.scss' | |
} | |
} | |
}, | |
autoprefixer: { | |
dist: { | |
files: { | |
'www/assets/css/admin-interface.css': 'www/assets/css/admin-interface.css' | |
} | |
} | |
}, | |
imageEmbed: { | |
dist: { | |
src: ['www/assets/css/admin-interface.css'], | |
dest: 'www/assets/css/admin-interface.css', | |
options: { | |
baseDir: 'www', | |
deleteAfterEncoding: false | |
} | |
} | |
}, | |
requirejs: { | |
options: { | |
baseUrl: 'www/assets/js/', | |
mainConfigFile: 'www/assets/js/init.js', | |
include: ['app'], | |
keepBuildDir: true | |
}, | |
dev: { | |
options: { | |
out: 'www/assets/js/dev.js' | |
} | |
}, | |
prod: { | |
options: { | |
out: 'www/assets/js/prod.js' | |
} | |
} | |
}, | |
retire: { | |
files: ['www/assets/js/lib/*.js'] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-sass'); | |
grunt.loadNpmTasks('grunt-autoprefixer'); | |
grunt.loadNpmTasks('grunt-image-embed'); | |
grunt.loadNpmTasks('grunt-contrib-requirejs'); | |
grunt.loadNpmTasks('grunt-retire'); | |
grunt.registerTask('default', ['watch']); | |
grunt.registerTask('build', ['requirejs', 'retire', 'sass', 'autoprefixer', 'imageEmbed']); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requirejs data-main | |
requirejs.config( | |
{ | |
baseUrl: '/assets/js/lib/', | |
paths: { | |
'so-much-stuff': '../my-app[/...]', | |
'underscore': 'lodash', | |
'marionette': 'backbone.marionette', | |
'Handlebars': 'handlebars', | |
'domReady': 'require.domReady', | |
}, | |
shim: { | |
// shim all the things | |
} | |
}); | |
requirejs(['app', 'domReady!'], function(App) | |
{ | |
App.start(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
init.js
=> best practice suggestion: rename it tomain.js
rewrite requirejs([], function... section to:
Remove the baseUrl, it actually makes it harder for
requirejs
to auto resolve pathsafter rename of init.js to main.js you should be able to run a config in your grunt file based on this: