Grunt preen and concat
Set up grunt with tasks for: * preen - deletes unused files from bower_components, configured in bower.json * concat - concatenates preened bower components, configured automagically from the preen config It's worth noting that this setup assumes the order of files within a package doesn't matter. This is usually true since we often include only one file from the package.
This commit is contained in:
parent
c8ad65efe0
commit
73f4f64351
10 changed files with 20841 additions and 26 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
21
Gruntfile.js
Normal file
21
Gruntfile.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
|
// build the concat config from the preen config
|
||||||
|
var components = [];
|
||||||
|
for (component in grunt.file.readJSON('bower.json').preen) {
|
||||||
|
components.push('bower_components/' + component + '/**/*.js');
|
||||||
|
}
|
||||||
|
|
||||||
|
grunt.initConfig({
|
||||||
|
concat: {
|
||||||
|
components: {
|
||||||
|
src: components,
|
||||||
|
dest: 'js-deps/bower_components.js',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
grunt.loadNpmTasks('grunt-preen');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||||
|
|
||||||
|
grunt.registerTask('default', ['preen', 'concat']);
|
||||||
|
};
|
25
README.md
25
README.md
|
@ -29,8 +29,29 @@ You should now be able to use the extension. If you need to reset your developme
|
||||||
Dependencies
|
Dependencies
|
||||||
============
|
============
|
||||||
Dependencies are managed by [bower](bower.io). You'll need to install
|
Dependencies are managed by [bower](bower.io). You'll need to install
|
||||||
node, npm, and bower to change them. If you add a dependency, please
|
node, npm, and bower to change them.
|
||||||
only check in the package files that we actually need.
|
|
||||||
|
### Adding a bower component
|
||||||
|
|
||||||
|
Add the package to bower.json under 'dependencies' or
|
||||||
|
|
||||||
|
`bower install *package-name* --save`
|
||||||
|
|
||||||
|
Next update the "preen" config in bower.json with the list of files we will
|
||||||
|
actually use from the new package, e.g.:
|
||||||
|
```
|
||||||
|
"preen": {
|
||||||
|
"new-package": ["path/to/main.js", "directory/**/*.js"],
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Now, run `grunt` to delete unused package files and concatenate the
|
||||||
|
remaining javascript files into `js-deps/bower_components.js`. Note that
|
||||||
|
packages will be concatenated **in order** as specified in the preen
|
||||||
|
config.
|
||||||
|
|
||||||
|
Finally, stage and commit changes to bower.json, js-deps/bower_components.js,
|
||||||
|
and bower_components/. The latter should be limited to files we actually use.
|
||||||
|
|
||||||
Tests
|
Tests
|
||||||
=====
|
=====
|
||||||
|
|
|
@ -18,12 +18,7 @@
|
||||||
<script type="text/javascript" src="js-deps/nacl-common.js"></script>
|
<script type="text/javascript" src="js-deps/nacl-common.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/CryptoJS.js"></script>
|
<script type="text/javascript" src="js-deps/CryptoJS.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/curve255.js"></script>
|
<script type="text/javascript" src="js-deps/curve255.js"></script>
|
||||||
<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
|
<script type="text/javascript" src="js-deps/bower_components.js"></script>
|
||||||
<script type="text/javascript" src="bower_components/long/dist/Long.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/bytebuffer/dist/ByteBufferAB.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/protobuf/dist/ProtoBuf.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/underscore/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/backbone/backbone.js"></script>
|
|
||||||
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
|
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
|
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,14 @@
|
||||||
"protobuf": "~3.8.0",
|
"protobuf": "~3.8.0",
|
||||||
"jquery": "~2.1.1",
|
"jquery": "~2.1.1",
|
||||||
"bootstrap": "~3.3.0"
|
"bootstrap": "~3.3.0"
|
||||||
|
},
|
||||||
|
"preen": {
|
||||||
|
"jquery": ["dist/jquery.js"],
|
||||||
|
"long": ["dist/Long.js"],
|
||||||
|
"bytebuffer": ["dist/ByteBufferAB.js"],
|
||||||
|
"protobuf": ["dist/ProtoBuf.js"],
|
||||||
|
"underscore": ["underscore.js"],
|
||||||
|
"backbone": ["backbone.js"],
|
||||||
|
"bootstrap": ["dist/css/bootstrap.css"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,12 +125,7 @@
|
||||||
<script type="text/javascript" src="js-deps/nacl-common.js"></script>
|
<script type="text/javascript" src="js-deps/nacl-common.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/CryptoJS.js"></script>
|
<script type="text/javascript" src="js-deps/CryptoJS.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/curve255.js"></script>
|
<script type="text/javascript" src="js-deps/curve255.js"></script>
|
||||||
<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
|
<script type="text/javascript" src="js-deps/bower_components.js"></script>
|
||||||
<script type="text/javascript" src="bower_components/long/dist/Long.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/bytebuffer/dist/ByteBufferAB.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/protobuf/dist/ProtoBuf.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/underscore/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/backbone/backbone.js"></script>
|
|
||||||
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
|
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/mustache.js"></script>
|
<script type="text/javascript" src="js-deps/mustache.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
|
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
|
||||||
|
|
20772
js-deps/bower_components.js
Normal file
20772
js-deps/bower_components.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -93,12 +93,7 @@
|
||||||
<script type="text/javascript" src="js-deps/nacl-common.js"></script>
|
<script type="text/javascript" src="js-deps/nacl-common.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/CryptoJS.js"></script>
|
<script type="text/javascript" src="js-deps/CryptoJS.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/curve255.js"></script>
|
<script type="text/javascript" src="js-deps/curve255.js"></script>
|
||||||
<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
|
<script type="text/javascript" src="js-deps/bower_components.js"></script>
|
||||||
<script type="text/javascript" src="bower_components/long/dist/Long.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/bytebuffer/dist/ByteBufferAB.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/protobuf/dist/ProtoBuf.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/underscore/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="bower_components/backbone/backbone.js"></script>
|
|
||||||
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
|
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
|
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
|
||||||
<script type="text/javascript" src="js-deps/qrcode.min.js"></script>
|
<script type="text/javascript" src="js-deps/qrcode.min.js"></script>
|
||||||
|
|
11
package.json
Normal file
11
package.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name": "textsecure-chrome",
|
||||||
|
"repository": "https://github.com/WhisperSystems/TextSecure.git",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"grunt": "^0.4.5",
|
||||||
|
"grunt-contrib-concat": "^0.5.0",
|
||||||
|
"grunt-contrib-jshint": "~0.10.0",
|
||||||
|
"grunt-preen": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -126,12 +126,7 @@
|
||||||
<script type="text/javascript" src="../js-deps/nacl-common.js"></script>
|
<script type="text/javascript" src="../js-deps/nacl-common.js"></script>
|
||||||
<script type="text/javascript" src="../js-deps/CryptoJS.js"></script>
|
<script type="text/javascript" src="../js-deps/CryptoJS.js"></script>
|
||||||
<script type="text/javascript" src="../js-deps/curve255.js"></script>
|
<script type="text/javascript" src="../js-deps/curve255.js"></script>
|
||||||
<script type="text/javascript" src="../bower_components/jquery/dist/jquery.js"></script>
|
<script type="text/javascript" src="../js-deps/bower_components.js"></script>
|
||||||
<script type="text/javascript" src="../bower_components/long/dist/Long.js"></script>
|
|
||||||
<script type="text/javascript" src="../bower_components/bytebuffer/dist/ByteBufferAB.js"></script>
|
|
||||||
<script type="text/javascript" src="../bower_components/protobuf/dist/ProtoBuf.js"></script>
|
|
||||||
<script type="text/javascript" src="../bower_components/underscore/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../bower_components/backbone/backbone.js"></script>
|
|
||||||
<script type="text/javascript" src="../js-deps/backbone.localStorage.js"></script>
|
<script type="text/javascript" src="../js-deps/backbone.localStorage.js"></script>
|
||||||
<script type="text/javascript" src="../js-deps/mustache.js"></script>
|
<script type="text/javascript" src="../js-deps/mustache.js"></script>
|
||||||
<script type="text/javascript" src="../js-deps/libphonenumber_api-compiled.js"></script>
|
<script type="text/javascript" src="../js-deps/libphonenumber_api-compiled.js"></script>
|
||||||
|
|
Loading…
Reference in a new issue