-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build js and css assets from bower and grunt
Heavily based on @robvdl improvement
- Loading branch information
Showing
9 changed files
with
164 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
module.exports = function(grunt) { | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
|
||
concat: { | ||
js: { | ||
src: [ | ||
'bower_components/jquery/jquery.js', | ||
'bower_components/bootstrap/bootstrap/js/bootstrap.js', | ||
'bower_components/bootstrap-switch/build/js/bootstrap-switch.js', | ||
'bower_components/jqBootstrapValidation/dist/jqBootstrapValidation-1.3.7.js' | ||
], | ||
dest: '../lwp/static/js/bootstrap.js' | ||
}, | ||
css: { | ||
src: [ | ||
'bower_components/bootstrap/bootstrap/css/bootstrap.css', | ||
'bower_components/bootstrap/bootstrap/css/bootstrap-responsive.css', | ||
'bower_components/bootstrap-switch/build/css/bootstrap2/bootstrap-switch.css' | ||
], | ||
dest: '../lwp/static/css/bootstrap.css' | ||
} | ||
}, | ||
|
||
uglify: { | ||
compress: { | ||
files: { | ||
'../lwp/static/js/bootstrap.min.js': ['../lwp/static/js/bootstrap.js'] | ||
}, | ||
options: { | ||
mangle: true | ||
} | ||
} | ||
}, | ||
|
||
cssmin: { | ||
build: { | ||
src: '../lwp/static/css/bootstrap.css', | ||
dest: '../lwp/static/css/bootstrap.min.css' | ||
} | ||
}, | ||
|
||
copy: { | ||
main: { | ||
expand: true, | ||
cwd: 'bower_components/bootstrap/', | ||
src: 'img/*', | ||
dest: '../lwp/static/img/', | ||
flatten: true, | ||
filter: 'isFile', | ||
}, | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-contrib-cssmin'); | ||
|
||
grunt.registerTask('default', ['concat', 'uglify', 'cssmin', 'copy']); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
About this directory | ||
==================== | ||
|
||
In order to not pollute the root directory of this Python project with JS | ||
build tool files, we use a directory "jsbuild" for this. | ||
|
||
This just keeps the project a bit tidier and puts all frontend tools | ||
in one place. | ||
|
||
The npm node_modules and bower_components folders get created here. | ||
|
||
npm, bower, and grunt are all executed from the fabfile.py | ||
|
||
The fabfile.py is then invoked by the debian packaging process. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "lwp-bower", | ||
"version": "0.1", | ||
"authors": [ | ||
"Rob van der Linde <robvdl@gmail.com>", | ||
"Claudio Mignanti <c.mignanti@gmail.com>" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"jquery": "~2.0.3", | ||
"bootstrap": "git@github.com:alonisser/bower-bootstrap-2.3.2-legacy.git", | ||
"bootstrap-switch": "~2.0.1", | ||
"jqBootstrapValidation": "git@github.com:ReactiveRaven/jqBootstrapValidation.git" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "lwp-jsbuild", | ||
"description": "JavaScript build environment", | ||
"author": "Rob van der Linde", | ||
"tags": [], | ||
"repository": "https://github.com/robvdl/LXC-Web-Panel.git", | ||
"version": "0.1.1", | ||
"engines": { | ||
"node": ">=0.10.11" | ||
}, | ||
"devDependencies": { | ||
"bower": "~1.3.9", | ||
"grunt": "~0.4.5", | ||
"grunt-cli": "~0.1.13", | ||
"grunt-contrib-concat": "~0.5.0", | ||
"grunt-contrib-copy": "~0.7.0", | ||
"grunt-contrib-uglify": "~0.5.1", | ||
"grunt-contrib-cssmin": "~0.10.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
6dea09f
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.
cool
6dea09f
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.
check the jsbuild/package.json the url to repo is wrong, it still points to my fork rather than your own repo.
6dea09f
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.
Also, this is more just for information, as I'm not expecting you to switch away from Grunt or anything, but in other projects I have started using Gulp + Browserify + Watchify as an assets chain and renamed the "jsbuild" folder just to "frontend".
Though Grunt itself is fine, doing this with Gulp and using Watchify is very fast for doing constant rebuilds. I also started using React.js and React-Bootstrap, which changes the JS code style completely.
Browserify basically means you can import JS modules using require() statements, then browserify packages everything up in one huge .js file, this includes all the dependencies: Bootstrap, React, React-Bootstrap and your own code all packaged into one .js file for the entire site.
I haven't done any of this to my LXC Web Panel fork however.