Skip to content

Commit 6fd2a73

Browse files
committed
- Added default grunt task
- Updated all grunt tasks to their latest versions - Added BrowserSync for dev - Now using grunt-contrib-watch
1 parent b5960d4 commit 6fd2a73

File tree

5 files changed

+50
-128
lines changed

5 files changed

+50
-128
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ build/
2828
#-----------------------------
2929
_db.php
3030
regexr.css
31+
*.map

Gruntfile.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
var path = require("path");
22
var uglify = require("uglify-js");
33

4-
var folderMount = function folderMount(connect, point) {
5-
return connect.static(path.resolve(point));
6-
};
7-
84
module.exports = function (grunt) {
9-
105
/*
116
Load all the tasks we need
7+
*/
8+
9+
/*
10+
*************************************
11+
**** About: grunt-yui-compressor ****
12+
*************************************
1213
Usually we use uglifyJS for code minification.
1314
However uglify breaks the Unicode characters Codemirror uses in its RegEx expressions,
1415
whereas yui does not.
1516
*/
1617
grunt.loadNpmTasks("grunt-yui-compressor");
18+
grunt.loadNpmTasks("grunt-contrib-watch");
1719
grunt.loadNpmTasks("grunt-contrib-uglify");
1820
grunt.loadNpmTasks("grunt-contrib-sass");
1921
grunt.loadNpmTasks("grunt-contrib-connect");
2022
grunt.loadNpmTasks("grunt-contrib-clean");
2123
grunt.loadNpmTasks("grunt-contrib-htmlmin");
2224
grunt.loadNpmTasks("grunt-contrib-copy");
2325
grunt.loadNpmTasks("grunt-contrib-concat");
24-
grunt.loadTasks("tasks/");
25-
26+
grunt.loadNpmTasks('grunt-browser-sync');
2627

2728
grunt.initConfig({
2829
pkg: grunt.file.readJSON("package.json"),
@@ -76,21 +77,25 @@ module.exports = function (grunt) {
7677
}
7778
},
7879

79-
watchSass: {
80-
run: {
81-
options: {
82-
compass: true,
83-
// In prep-tasks, we change the style for a build, to nested;
84-
style: "nested", // Can be nested, compact, compressed, expanded
85-
"line-numbers": true,
86-
precision: 2,
80+
browserSync: {
81+
bsFiles: {
82+
src: ["css/*.css", "js/**/.js", "index.html"]
83+
},
84+
options: {
85+
server: {
86+
baseDir: "./"
8787
},
88-
files: {
89-
"css/regexr.css":"scss/regexr.scss"
90-
}
88+
watchTask: true
9189
}
9290
},
9391

92+
watch: {
93+
sass: {
94+
files: ['scss/**/*.scss'],
95+
tasks: ['sass'],
96+
},
97+
},
98+
9499
cssmin: {
95100
options: {
96101
report: false
@@ -124,9 +129,9 @@ module.exports = function (grunt) {
124129
options: {
125130
hostname: "*",
126131
keepalive:true,
127-
middleware: function (connect, options) {
128-
return [folderMount(connect, grunt.config.get("deployFolder"))]
129-
}
132+
useAvailablePort: true,
133+
open: true,
134+
base: './build/'
130135
}
131136
}
132137
},
@@ -163,6 +168,12 @@ module.exports = function (grunt) {
163168
grunt.file.write(grunt.config.get("deployFolder")+"index.html.tmp", output);
164169
});
165170

171+
grunt.registerTask("default", [
172+
"sass",
173+
"browserSync",
174+
"watch",
175+
]);
176+
166177
grunt.registerTask("build", [
167178
"clean:build",
168179
"sass",
@@ -192,7 +203,7 @@ module.exports = function (grunt) {
192203
}
193204
});
194205
}
195-
206+
196207
if (missing.length) {
197208
// \x07 == beep sound in the terminal.
198209
grunt.log.warn("\x07Missing ", missing.length + " scripts.\n\t" + missing.join("\n\t"));

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,8 @@ After node is setup, install the other dependencies. You may want to familiarize
3030
# Install all the dependencies from package.json
3131
npm install
3232

33-
### Setup
34-
#### Compile sass
35-
The only requirement for development is to compile the sass files. This can be achieved manually via ```grunt sass;```
36-
or for development you can watch for changes use ```grunt watchSass;```
37-
You can also use any third-party sass compiler. Examples are; Using a WebStorm watcher or CodeKits built compiler.
38-
39-
#### Other setup
40-
There is no other setup required, grunt build mainly prepares the source for deployment.
33+
### Development
34+
Run ```grunt;``` to start a local dev server. grunt will also watch for changes in the local sass and javascript files.
4135

4236
### Building
4337
To prepare the site for a deploy run:
@@ -52,6 +46,7 @@ This command will:
5246
* Inject js/index.template.js into the index.html file
5347
* Minify the index.html file
5448

49+
5550
# Code Style
5651
If you would like to contribute back to RegExr.com please send us pull requests.
5752
Please make sure they are well formatted and follow the style specified out in the existing files.

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
{
22
"name": "RegExr",
3-
"version": "0.0.1",
3+
"version": "2.0.0",
44
"repository": "http://github.com/gskinner/regexr/regexr.git",
55
"devDependencies": {
6-
"grunt": "~0.4.2",
7-
"grunt-contrib-htmlmin": "~0.1.3",
8-
"grunt-contrib-sass": "~0.6.0",
9-
"grunt-yui-compressor": "~0.3.0",
10-
"grunt-contrib-connect": "~0.6.0",
11-
"grunt-contrib-clean": "~0.5.0",
12-
"grunt-contrib-copy": "~0.5.0",
13-
"uglify-js": "~2.4.11",
14-
"grunt-contrib-uglify": "^0.4.0",
15-
"grunt-contrib-concat": "^0.4.0"
6+
"grunt": "^0.4.5",
7+
"grunt-browser-sync": "^2.0.0",
8+
"grunt-contrib-clean": "^0.6.0",
9+
"grunt-contrib-concat": "^0.5.0",
10+
"grunt-contrib-connect": "^0.9.0",
11+
"grunt-contrib-copy": "^0.7.0",
12+
"grunt-contrib-htmlmin": "^0.4.0",
13+
"grunt-contrib-sass": "^0.9.2",
14+
"grunt-contrib-uglify": "^0.8.0",
15+
"grunt-contrib-watch": "^0.6.1",
16+
"grunt-yui-compressor": "^0.3.3",
17+
"uglify-js": "^2.4.16"
1618
},
1719
"engine": "node >= 0.10.24"
1820
}

tasks/watchSass.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)