Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 39bac0b

Browse files
committed
Merge pull request #5776 from adobe/jasonsanjose/yeoman
Add concat, compile and minify Grunt tasks
2 parents 5e6664a + ef1bac2 commit 39bac0b

10 files changed

Lines changed: 225 additions & 39 deletions

File tree

.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
Thumbs.db
2-
src/brackets.css
3-
src/brackets.min.css
42

53
# ignore jenkins build info
64
/build.prop
@@ -11,19 +9,22 @@ src/brackets.min.css
119

1210
# ignore compiled files
1311
/dist
12+
/src/.index.html
13+
/src/styles/brackets.min.css
14+
/src/styles/brackets.min.css.map
1415

1516
# ignore everything in the dev extension directory EXCEPT the README
1617
# (so that the directory is non-empty and can be in git)
17-
src/extensions/dev/*
18-
!src/extensions/dev/README
18+
/src/extensions/dev/*
19+
!/src/extensions/dev/README
1920

20-
src/extensions/disabled
21+
/src/extensions/disabled
2122

2223
#OSX .DS_Store files
2324
.DS_Store
2425

2526
# unit test working directory
26-
test/results
27+
/test/results
2728

2829
# Netbeans
2930
/nbproject
@@ -32,4 +33,4 @@ test/results
3233
.idea
3334

3435
# Files that can be automatically downloaded that we don't want to ship with our builds
35-
src/extensibility/node/node_modules/request/tests/
36+
/src/extensibility/node/node_modules/request/tests/

Gruntfile.js

Lines changed: 160 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,152 @@
2424
module.exports = function (grunt) {
2525
'use strict';
2626

27+
// load dependencies
28+
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-targethtml', 'grunt-usemin']});
29+
grunt.loadTasks('tasks');
30+
2731
var common = require("./tasks/lib/common")(grunt);
2832

2933
// Project configuration.
3034
grunt.initConfig({
3135
pkg : grunt.file.readJSON("package.json"),
36+
clean: {
37+
dist: {
38+
files: [{
39+
dot: true,
40+
src: [
41+
'dist',
42+
'src/.index.html',
43+
'src/styles/brackets.css'
44+
]
45+
}]
46+
}
47+
},
48+
copy: {
49+
dist: {
50+
files: [
51+
{
52+
'dist/index.html': 'src/.index.html'
53+
},
54+
/* static files */
55+
{
56+
expand: true,
57+
dest: 'dist/',
58+
cwd: 'src/',
59+
src: [
60+
'nls/{,*/}*.js',
61+
'xorigin.js',
62+
'dependencies.js',
63+
'thirdparty/requirejs/require.js',
64+
'LiveDevelopment/launch.html'
65+
]
66+
},
67+
/* extensions and CodeMirror modes */
68+
{
69+
expand: true,
70+
dest: 'dist/',
71+
cwd: 'src/',
72+
src: [
73+
'extensibility/**/*',
74+
'!extensions/default/*/unittest-files/**/*',
75+
'!extensions/default/*/unittests.js',
76+
'extensions/default/*/**/*',
77+
'thirdparty/CodeMirror2/addon/{,*/}*',
78+
'thirdparty/CodeMirror2/keymap/{,*/}*',
79+
'thirdparty/CodeMirror2/lib/{,*/}*',
80+
'thirdparty/CodeMirror2/mode/{,*/}*',
81+
'thirdparty/CodeMirror2/theme/{,*/}*',
82+
'thirdparty/i18n/*.js',
83+
'thirdparty/text/*.js'
84+
]
85+
},
86+
/* styles, fonts and images */
87+
{
88+
expand: true,
89+
dest: 'dist/styles',
90+
cwd: 'src/styles',
91+
src: ['jsTreeTheme.css', 'fonts/{,*/}*.*', 'images/*', 'brackets.min.css*']
92+
}
93+
]
94+
}
95+
},
96+
less: {
97+
dist: {
98+
files: {
99+
"src/styles/brackets.min.css": "src/styles/brackets.less"
100+
},
101+
options: {
102+
compress: true,
103+
sourceMap: true,
104+
sourceMapFilename: 'src/styles/brackets.min.css.map',
105+
outputSourceFiles: true,
106+
sourceMapRootpath: '',
107+
sourceMapBasepath: 'src/styles'
108+
}
109+
}
110+
},
111+
requirejs: {
112+
dist: {
113+
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
114+
options: {
115+
// `name` and `out` is set by grunt-usemin
116+
baseUrl: 'src',
117+
optimize: 'uglify2',
118+
// TODO: Figure out how to make sourcemaps work with grunt-usemin
119+
// https://github.com/yeoman/grunt-usemin/issues/30
120+
generateSourceMaps: true,
121+
useSourceUrl: true,
122+
// required to support SourceMaps
123+
// http://requirejs.org/docs/errors.html#sourcemapcomments
124+
preserveLicenseComments: false,
125+
useStrict: true,
126+
// Disable closure, we want define/require to be globals
127+
wrap: false,
128+
exclude: ["text!config.json"],
129+
uglify2: {} // https://github.com/mishoo/UglifyJS2
130+
}
131+
}
132+
},
133+
targethtml: {
134+
dist: {
135+
files: {
136+
'src/.index.html': 'src/index.html'
137+
}
138+
}
139+
},
140+
useminPrepare: {
141+
options: {
142+
dest: 'dist'
143+
},
144+
html: 'src/.index.html'
145+
},
146+
usemin: {
147+
options: {
148+
dirs: ['dist']
149+
},
150+
html: ['dist/{,*/}*.html']
151+
},
152+
htmlmin: {
153+
dist: {
154+
options: {
155+
/*removeCommentsFromCDATA: true,
156+
// https://github.com/yeoman/grunt-usemin/issues/44
157+
//collapseWhitespace: true,
158+
collapseBooleanAttributes: true,
159+
removeAttributeQuotes: true,
160+
removeRedundantAttributes: true,
161+
useShortDoctype: true,
162+
removeEmptyAttributes: true,
163+
removeOptionalTags: true*/
164+
},
165+
files: [{
166+
expand: true,
167+
cwd: 'src',
168+
src: '*.html',
169+
dest: 'dist'
170+
}]
171+
}
172+
},
32173
meta : {
33174
src : [
34175
'src/**/*.js',
@@ -144,16 +285,9 @@ module.exports = function (grunt) {
144285
linux: "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets"
145286
}
146287
});
147-
148-
// load dependencies
149-
grunt.loadTasks('tasks');
150-
grunt.loadNpmTasks('grunt-contrib-jasmine');
151-
grunt.loadNpmTasks('grunt-contrib-jshint');
152-
grunt.loadNpmTasks('grunt-contrib-watch');
153-
grunt.loadNpmTasks('grunt-jasmine-node');
154288

155289
// task: install
156-
grunt.registerTask('install', ['write-config']);
290+
grunt.registerTask('install', ['write-config', 'less']);
157291

158292
// task: test
159293
grunt.registerTask('test', ['jshint:all', 'jasmine']);
@@ -163,6 +297,24 @@ module.exports = function (grunt) {
163297
// Update sprint number in package.json and rewrite src/config.json
164298
grunt.registerTask('set-sprint', ['update-sprint-number', 'write-config']);
165299

300+
// task: build
301+
grunt.registerTask('build', [
302+
'jshint:src',
303+
'jasmine',
304+
'clean',
305+
'less',
306+
'targethtml',
307+
'useminPrepare',
308+
'htmlmin',
309+
'requirejs',
310+
'concat',
311+
/*'cssmin',*/
312+
/*'uglify',*/
313+
'copy',
314+
'usemin',
315+
'build-config'
316+
]);
317+
166318
// Default task.
167319
grunt.registerTask('default', ['test']);
168320
};

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
"grunt-contrib-watch": "0.3.1",
2424
"grunt-contrib-jasmine": "0.4.2",
2525
"grunt-template-jasmine-requirejs": "0.1.0",
26+
"grunt-contrib-cssmin": "0.6.0",
27+
"grunt-contrib-clean": "0.4.1",
28+
"grunt-contrib-copy": "0.4.1",
29+
"grunt-contrib-htmlmin": "0.1.3",
30+
"grunt-contrib-less": "0.8.2",
31+
"grunt-contrib-requirejs": "0.4.1",
32+
"grunt-contrib-uglify": "0.2.0",
33+
"grunt-contrib-concat": "0.3.0",
34+
"grunt-contrib-watch": "0.4.3",
35+
"grunt-targethtml": "0.2.6",
36+
"grunt-usemin": "0.1.11",
37+
"load-grunt-tasks": "0.2.0",
2638
"q": "0.9.2",
2739
"jshint": "2.1.4"
2840
},

src/brackets.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,5 @@ define(function (require, exports, module) {
383383
// Dispatch htmlReady event
384384
_beforeHTMLReady();
385385
AppInit._dispatchReady(AppInit.HTML_READY);
386-
387386
$(window.document).ready(_onReady);
388387
});

src/config.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@
3838
"phantomjs": "1.9.0-1",
3939
"grunt-lib-phantomjs": "0.3.0",
4040
"grunt-contrib-jshint": "0.6.0",
41-
"grunt-contrib-watch": "0.3.1",
41+
"grunt-contrib-watch": "0.4.3",
4242
"grunt-contrib-jasmine": "0.4.2",
4343
"grunt-template-jasmine-requirejs": "0.1.0",
44+
"grunt-contrib-cssmin": "0.6.0",
45+
"grunt-contrib-clean": "0.4.1",
46+
"grunt-contrib-copy": "0.4.1",
47+
"grunt-contrib-htmlmin": "0.1.3",
48+
"grunt-contrib-less": "0.8.2",
49+
"grunt-contrib-requirejs": "0.4.1",
50+
"grunt-contrib-uglify": "0.2.0",
51+
"grunt-contrib-concat": "0.3.0",
52+
"grunt-targethtml": "0.2.6",
53+
"grunt-usemin": "0.1.11",
54+
"load-grunt-tasks": "0.2.0",
4455
"q": "0.9.2",
4556
"jshint": "2.1.4"
4657
},

src/index.html

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@
3232
<!-- NOTE: All scripts must be external for Chrome App support: http://developer.chrome.com/apps/app_csp.html -->
3333

3434
<!-- Warn about failed cross origin requests in Chrome -->
35-
<script type="application/javascript" src="xorigin.js">
36-
</script>
37-
38-
<!-- TODO (Issue #278): switch between runtime LESS compilation in dev mode and precompiled version -->
39-
<link rel="stylesheet/less" href="styles/brackets.less">
40-
<script src="thirdparty/less-1.4.2.min.js"></script>
41-
<script src="thirdparty/mustache/mustache.js"></script>
42-
<!-- <link rel="stylesheet" href="brackets.min.css"> -->
35+
<script type="application/javascript" src="xorigin.js"></script>
4336

37+
<link rel="stylesheet" type="text/css" href="thirdparty/CodeMirror2/lib/codemirror.css">
38+
<!--(if target dev)><!-->
39+
<link rel="stylesheet" type="text/less" href="styles/brackets.less">
40+
<!--<!(endif)-->
41+
<!--(if target dist)>
42+
<link rel="stylesheet" type="text/css" href="styles/brackets.min.css">
43+
<!--<!(endif)-->
44+
4445
<!-- JavaScript -->
4546

4647
<!-- Pre-load third party scripts that cannot be async loaded. -->
48+
<!-- build:js thirdparty/thirdparty.min.js -->
49+
<script src="thirdparty/less-1.4.2.min.js"></script>
50+
<script src="thirdparty/mustache/mustache.js"></script>
4751
<script src="thirdparty/jquery-2.0.1.min.js"></script>
4852
<script src="thirdparty/CodeMirror2/lib/codemirror.js"></script>
4953
<script src="thirdparty/CodeMirror2/addon/fold/xml-fold.js"></script>
@@ -59,6 +63,7 @@
5963

6064
<!-- JS for CodeMirror search support -->
6165
<script src="thirdparty/CodeMirror2/addon/search/searchcursor.js"></script>
66+
<!-- endbuild -->
6267

6368
</head>
6469
<body>
@@ -70,7 +75,9 @@
7075
-->
7176

7277
<!-- All other scripts are loaded through require. -->
78+
<!-- build:js main.js -->
7379
<script src="thirdparty/requirejs/require.js" data-main="main"></script>
80+
<!-- endbuild -->
7481

7582
<!-- Verify that all dependencies are loaded. -->
7683
<script src="dependencies.js"></script>

src/main.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ require.config({
3737
// The file system implementation. Change this value to use different
3838
// implementations (e.g. cloud-based storage).
3939
"fileSystemImpl" : "filesystem/impls/appshell/AppshellFileSystem"
40-
},
41-
// Use custom brackets property until CEF sets the correct navigator.language
42-
// NOTE: When we change to navigator.language here, we also should change to
43-
// navigator.language in ExtensionLoader (when making require contexts for each
44-
// extension).
40+
}
41+
});
42+
43+
// hack for r.js optimization, move locale to another config call
44+
45+
// Use custom brackets property until CEF sets the correct navigator.language
46+
// NOTE: When we change to navigator.language here, we also should change to
47+
// navigator.language in ExtensionLoader (when making require contexts for each
48+
// extension).
49+
require.config({
4550
locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language)
4651
});
4752

@@ -51,4 +56,3 @@ define(function (require, exports, module) {
5156
// Load the brackets module. This is a self-running module that loads and runs the entire application.
5257
require("brackets");
5358
});
54-

src/styles/brackets_shared.less

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
* processing order.
3232
*/
3333

34-
/* CSS imports */
35-
36-
// CodeMirror
37-
// Must wrap in quotes to avoid issue #1015 (true for all relative URLs to non-LESS files)
38-
@import "../thirdparty/CodeMirror2/lib/codemirror.css";
39-
4034
/* LESS imports */
4135

4236
// Bootstrap @ v.2.3.1

src/utils/ExtensionLoader.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ define(function (require, exports, module) {
6969
* C:\Users\<user>\AppData\Roaming\Brackets\extensions\user on windows.
7070
*/
7171
function getUserExtensionPath() {
72-
return brackets.app.getApplicationSupportDirectory() + "/extensions/user";
72+
if (brackets.app.getApplicationSupportDirectory) {
73+
return brackets.app.getApplicationSupportDirectory() + "/extensions/user";
74+
}
75+
76+
return null;
7377
}
7478

7579
/**

src/utils/ShellAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ define(function (require, exports, module) {
5656
// which we have to return true (issue #3152).
5757
return (eventName === Commands.FILE_CLOSE_WINDOW);
5858
}
59-
var promise, e = new Error(), stackDepth = e.stack.split("\n").length;
59+
60+
// Use E for Error so that uglify doesn't change this to simply Error()
61+
var promise, E = Error, e = new E(), stackDepth = e.stack.split("\n").length;
6062

6163
// This function should *only* be called as a top-level function. If the current
6264
// stack depth is > 2, it is most likely because we are at a breakpoint.

0 commit comments

Comments
 (0)