-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add concat, compile and minify Grunt tasks #5776
Changes from 2 commits
86c003c
3b9c5c0
fabd7b0
f51764b
342d42d
b68d69c
a82ae3d
291d664
7fd497f
3bd69db
0332a1f
fe09112
ef1bac2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,121 @@ | |
module.exports = function (grunt) { | ||
'use strict'; | ||
|
||
// load dependencies | ||
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-usemin']}); | ||
grunt.loadTasks('tasks'); | ||
|
||
var common = require("./tasks/lib/common")(grunt); | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg : grunt.file.readJSON("package.json"), | ||
clean: { | ||
dist: ['dist'] | ||
}, | ||
copy: { | ||
dist: { | ||
files: [ | ||
/* static files */ | ||
{ | ||
expand: true, | ||
dest: 'dist/', | ||
cwd: 'src/', | ||
src: [ | ||
'config.json', | ||
'nls/{,*/}*.js', | ||
'xorigin.js', | ||
'dependencies.js', | ||
'thirdparty/requirejs/require.js', | ||
'thirdparty/CodeMirror2/**/*', | ||
'thirdparty/i18n/*.js', | ||
'thirdparty/text/*.js' | ||
] | ||
}, | ||
/* extensions and CodeMirror modes */ | ||
{ | ||
expand: true, | ||
dest: 'dist/', | ||
cwd: 'src/', | ||
src: [ | ||
'extensibility/**/*', | ||
'extensions/default/**/*', | ||
'thirdparty/CodeMirror2/**/*', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to keep these files in |
||
'thirdparty/i18n/*.js', | ||
'thirdparty/text/*.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need these for |
||
] | ||
}, | ||
/* styles, fonts and images */ | ||
{ | ||
expand: true, | ||
dest: 'dist/styles', | ||
cwd: 'src/styles', | ||
src: ['jsTreeTheme.css', 'fonts/{,*/}*.*', 'images/*'] | ||
} | ||
] | ||
} | ||
}, | ||
less: { | ||
css: { | ||
files: { | ||
"src/styles/brackets.css": "src/styles/brackets.less" | ||
} | ||
} | ||
}, | ||
requirejs: { | ||
dist: { | ||
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js | ||
options: { | ||
// `name` and `out` is set by grunt-usemin | ||
baseUrl: 'src', | ||
optimize: 'none', | ||
// TODO: Figure out how to make sourcemaps work with grunt-usemin | ||
// https://github.com/yeoman/grunt-usemin/issues/30 | ||
//generateSourceMaps: true, | ||
// required to support SourceMaps | ||
// http://requirejs.org/docs/errors.html#sourcemapcomments | ||
preserveLicenseComments: true, | ||
useStrict: true, | ||
// Disable closure, we want define/require to be globals | ||
wrap: false | ||
//uglify2: {} // https://github.com/mishoo/UglifyJS2 | ||
} | ||
} | ||
}, | ||
useminPrepare: { | ||
options: { | ||
dest: 'dist' | ||
}, | ||
html: 'src/index.html' | ||
}, | ||
usemin: { | ||
options: { | ||
dirs: ['dist'] | ||
}, | ||
html: ['dist/{,*/}*.html'], | ||
css: ['dist/css/{,*/}*.css'] | ||
}, | ||
htmlmin: { | ||
dist: { | ||
options: { | ||
/*removeCommentsFromCDATA: true, | ||
// https://github.com/yeoman/grunt-usemin/issues/44 | ||
//collapseWhitespace: true, | ||
collapseBooleanAttributes: true, | ||
removeAttributeQuotes: true, | ||
removeRedundantAttributes: true, | ||
useShortDoctype: true, | ||
removeEmptyAttributes: true, | ||
removeOptionalTags: true*/ | ||
}, | ||
files: [{ | ||
expand: true, | ||
cwd: 'src', | ||
src: '*.html', | ||
dest: 'dist' | ||
}] | ||
} | ||
}, | ||
meta : { | ||
src : [ | ||
'src/**/*.js', | ||
|
@@ -144,13 +254,6 @@ module.exports = function (grunt) { | |
linux: "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets" | ||
} | ||
}); | ||
|
||
// load dependencies | ||
grunt.loadTasks('tasks'); | ||
grunt.loadNpmTasks('grunt-contrib-jasmine'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('grunt-jasmine-node'); | ||
|
||
// task: install | ||
grunt.registerTask('install', ['write-config']); | ||
|
@@ -164,5 +267,17 @@ module.exports = function (grunt) { | |
grunt.registerTask('set-sprint', ['update-sprint-number', 'write-config']); | ||
|
||
// Default task. | ||
grunt.registerTask('default', ['test']); | ||
grunt.registerTask('default', [ | ||
'test', | ||
'less', | ||
'clean', | ||
'useminPrepare', | ||
'htmlmin', | ||
'requirejs', | ||
'concat', | ||
'cssmin', | ||
'uglify', | ||
'copy', | ||
'usemin' | ||
]); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,17 @@ | |
<script type="application/javascript" src="xorigin.js"> | ||
</script> | ||
|
||
<!-- TODO (Issue #278): switch between runtime LESS compilation in dev mode and precompiled version --> | ||
<link rel="stylesheet/less" href="styles/brackets.less"> | ||
<script src="thirdparty/less-1.4.2.min.js"></script> | ||
<script src="thirdparty/mustache/mustache.js"></script> | ||
<!-- <link rel="stylesheet" href="brackets.min.css"> --> | ||
|
||
<!-- build:css styles/brackets.min.css --> | ||
<link rel="stylesheet" type="text/css" href="thirdparty/CodeMirror2/lib/codemirror.css"> | ||
<link rel="stylesheet" type="text/css" href="styles/brackets.css"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means that we are no longer dynamically generating CSS at startup from our LESS files. Developers will need to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if .css file was automatically generated when changes were made so we'd get the best of both worlds. The BracketsLESS extension does this, but I'm not sure if it works when you update an @imported .less file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll see if I can have an alternate index.html that lets us keep our current workflow of dynamically compiling LESS at startup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. I added another task |
||
<!-- endbuild --> | ||
|
||
<!-- JavaScript --> | ||
|
||
<!-- Pre-load third party scripts that cannot be async loaded. --> | ||
<!-- build:js thirdparty/thirdparty.min.js --> | ||
<script src="thirdparty/less-1.4.2.min.js"></script> | ||
<script src="thirdparty/mustache/mustache.js"></script> | ||
<script src="thirdparty/jquery-2.0.1.min.js"></script> | ||
<script src="thirdparty/CodeMirror2/lib/codemirror.js"></script> | ||
<script src="thirdparty/CodeMirror2/addon/fold/xml-fold.js"></script> | ||
|
@@ -52,9 +54,8 @@ | |
<script src="thirdparty/CodeMirror2/addon/edit/closebrackets.js"></script> | ||
<script src="thirdparty/CodeMirror2/addon/edit/closetag.js"></script> | ||
<script src="thirdparty/CodeMirror2/addon/selection/active-line.js"></script> | ||
|
||
<!-- JS for CodeMirror search support --> | ||
<script src="thirdparty/CodeMirror2/addon/search/searchcursor.js"></script> | ||
<!-- endbuild --> | ||
|
||
</head> | ||
<body> | ||
|
@@ -66,7 +67,9 @@ | |
--> | ||
|
||
<!-- All other scripts are loaded through require. --> | ||
<script src="thirdparty/requirejs/require.js" data-main="brackets"></script> | ||
<!-- build:js main.js --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could see the change caused by the build:js for thirdparty.min.js, but the only difference I see here is that the attributes switched order... otherwise, the script tag seems exactly the same. What should this be doing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sets up configuration used by the requirejs (r.js) task. You're right that it sort of looks like a no-op though. Anyhow, the config is printed to the terminal:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, that's like magic voodoo. There's nothing in the Gruntfile that runs r.js (looks like usemin takes care of it). |
||
<script src="thirdparty/requirejs/require.js" data-main="main"></script> | ||
<!-- endbuild --> | ||
|
||
<!-- Verify that all dependencies are loaded. --> | ||
<script src="dependencies.js"></script> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global require, window, brackets, navigator */ | ||
(function () { | ||
"use strict"; | ||
|
||
require.config({ | ||
paths: { | ||
"text" : "thirdparty/text/text", | ||
"i18n" : "thirdparty/i18n/i18n" | ||
} | ||
}); | ||
|
||
// hack for r.js optimization | ||
require.config({ | ||
locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language) | ||
}); | ||
|
||
require(["brackets"], function (brackets) {}); | ||
}()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need this for finding the extension manager node domain.