Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Got JS source maps working, finally.

  • Loading branch information...
commit c0ac218a9165112e22b69ed5fb076734f6e4204b 1 parent 80a2069
@craveytrain authored
View
248 Gruntfile.js
@@ -3,120 +3,136 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
-
- copy: {
- dist: {
- files: [
- {
- cwd: 'source/',
- expand: true,
- src: ['**', '!stylesheets/**'],
- dest: 'build/'
- }
- ]
- }
- },
-
- render: {
- content: ['content/**/*.md'],
- target: 'build',
- templates: 'templates',
- },
-
- jade: {
- options: {
- pretty: true
- }
- },
-
- stylus: {
- compile: {
- options: {
- linenos: true
- },
- files: {
- 'build/css/default.css': 'source/stylesheets/default.styl'
- }
- }
- },
-
- uglify: {
- dist: {
- options: {
- sourceMap: 'build/scripts/main.min.js.map',
- sourceMappingURL: 'main.min.js.map',
- prefix: '2'
- },
- files: {
- 'build/scripts/main.min.js': 'build/scripts/main.js'
- }
- }
- },
-
- watch: {
- css: {
- files: 'source/stylesheets/**/*.styl',
- tasks: ['stylus'],
- options: {
- interrupt: true
- }
- },
-
- templates: {
- files: ['**/*.yml', 'templates/**/*.jade', 'content/**/*.md'],
- tasks: ['render'],
- options: {
- interrupt: true
- }
- },
-
- staticFiles: {
- files: ['source/**', '!source/stylesheets/**'],
- tasks: ['copy'],
- options: {
- interrupt: true
- }
- }
- },
-
- jshint: {
- options: {
- jshintrc: '.jshintrc'
- },
- grunt: ['Gruntfile.js', 'lib/**/*.js', 'tasks/**/*.js'],
- site: ['source/**/*.js']
-
- },
-
- htmlmin: {
- dist: {
- options: {
- removeComments: true,
- removeCommentsFromCDATA: true,
- removeCDATASectionsFromCDATA: true,
- collapseWhitespace: true,
- collapseBooleanAttributes: true,
- removeRedundantAttributes: true,
- removeEmptyAttributes: true,
- removeOptionalTags: true
- },
- files: {
- 'build/**/*.html': 'build/**/*.html'
- }
- }
- },
-
- connect: {
- server: {
- options: {
- port: 4000,
- base: 'build'
- }
- }
- },
-
- clean: ['build']
+ pkg: grunt.file.readJSON('package.json'),
+
+ copy: {
+ dist: {
+ files: [
+ {
+ cwd: 'source/',
+ expand: true,
+ src: ['**', '!stylesheets/**'],
+ dest: 'build/'
+ }
+ ]
+ }
+ },
+
+ render: {
+ content: ['content/**/*.md'],
+ target: 'build',
+ templates: 'templates',
+ },
+
+ jade: {
+ options: {
+ pretty: true
+ }
+ },
+
+ stylus: {
+ compile: {
+ options: {
+ linenos: true
+ },
+ files: {
+ 'build/css/default.css': 'source/stylesheets/default.styl'
+ }
+ }
+ },
+
+ uglify: {
+ dist: {
+ options: {
+ report: 'gzip',
+ sourceMapRoot: '/',
+ sourceMap: 'build/js/source-map.js',
+ sourceMapPrefix: 1,
+ sourceMappingURL: '/js/source-map.js'
+ },
+ files: [
+ {
+ expand: true, // Enable dynamic expansion.
+ cwd: 'build/js/', // Src matches are relative to this path.
+ src: ['**/*.js'], // Actual pattern(s) to match.
+ dest: 'build/js/', // Destination path prefix.
+ ext: '.min.js' // Dest filepaths will have this extension.
+ }
+ ]
+ }
+ },
+
+ watch: {
+ css: {
+ files: 'source/stylesheets/**/*.styl',
+ tasks: ['stylus'],
+ options: {
+ interrupt: true
+ }
+ },
+
+ js: {
+ files: 'source/js/**/*.js',
+ tasks: ['uglify'],
+ options: {
+ interrupt: true
+ }
+ },
+
+ templates: {
+ files: ['**/*.yml', 'templates/**/*.jade', 'content/**/*.md'],
+ tasks: ['render'],
+ options: {
+ interrupt: true
+ }
+ },
+
+ staticFiles: {
+ files: ['source/**', '!source/stylesheets/**'],
+ tasks: ['copy'],
+ options: {
+ interrupt: true
+ }
+ }
+ },
+
+ jshint: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
+ grunt: ['Gruntfile.js', 'lib/**/*.js', 'tasks/**/*.js'],
+ site: ['source/**/*.js']
+
+ },
+
+ htmlmin: {
+ dist: {
+ options: {
+ removeComments: true,
+ removeCommentsFromCDATA: true,
+ removeCDATASectionsFromCDATA: true,
+ collapseWhitespace: true,
+ collapseBooleanAttributes: true,
+ removeRedundantAttributes: true,
+ removeEmptyAttributes: true,
+ removeOptionalTags: true
+ },
+ files: {
+ 'build/**/*.html': 'build/**/*.html'
+ }
+ }
+ },
+
+ connect: {
+ server: {
+ options: {
+ port: 4000,
+ base: 'build'
+ }
+ }
+ },
+
+ clean: ['build']
});
grunt.loadNpmTasks('grunt-contrib-jade');
@@ -130,9 +146,9 @@ grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadTasks('tasks');
-grunt.registerTask('build', ['clean', 'jshint', 'copy', 'render', 'stylus']);
+grunt.registerTask('build', ['clean', 'jshint', 'copy', 'render', 'stylus', 'uglify']);
grunt.registerTask('preview', ['build', 'connect', 'watch']);
-grunt.registerTask('package', ['clean', 'jshint', 'copy', 'render', 'stylus', 'uglify']);
+// grunt.registerTask('package', ['clean', 'jshint', 'copy', 'render', 'stylus', 'uglify']);
// Default task(s).
grunt.registerTask('default', ['build']);
View
1  site.yml
@@ -4,5 +4,6 @@ author: Mike Cravey
description: The blog of Mike Cravey (@craveytrain).
rss: /atom.xml
stylesheet: /css/default.css
+script: /js/main.min.js
domain: craveytrain.com
keywords: engineering, development, user interface
View
0  source/scripts/main.js → source/js/main.js
File renamed without changes
View
2  templates/includes/footer.jade
@@ -1,3 +1,3 @@
//- footer.page-footer(role='contentinfo')
block scripts
- script(src='/scripts/main.js')
+ script(src=script)
Please sign in to comment.
Something went wrong with that request. Please try again.