Skip to content

Commit

Permalink
feat(uglify/concat): Update UI-Grid build system to publish multiple …
Browse files Browse the repository at this point in the history
…files separated by features.

UI-Grid will now publish a base file with just the basic grid and multiple files for each individual
feature.

fix #5802
  • Loading branch information
Portugal, Marcelo authored and mportuga committed Mar 13, 2018
1 parent dcc43df commit 6d26274
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
34 changes: 26 additions & 8 deletions grunt/concat.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
const fs = require('fs');
const path = require('path');

const getDirectories = p => fs.readdirSync(p).filter(f => fs.statSync(path.join(p, f)).isDirectory());

function getFiles() {
const files = {
'<%= dist %>/release/<%= pkg.name %>.js': ['src/js/core/bootstrap.js', 'src/js/**/*.js', 'src/features/*/js/**/*.js', '.tmp/template.js'],
'<%= dist %>/release/<%= pkg.name %>.base.js': ['src/js/core/bootstrap.js', 'src/js/**/*.js', '.tmp/template.js']
};
const features = getDirectories('src/features/');

features.forEach((feat) => {
files[`<%= dist %>/release/<%= pkg.name %>.${feat}.js`] = [`src/features/${feat}/js/**/*.js`]
});

return files;
}

module.exports = {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['src/js/core/bootstrap.js', 'src/js/**/*.js', 'src/features/*/js/**/*.js', '.tmp/template.js'],
dest: '<%= dist %>/release/<%= pkg.name %>.js'
},
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
files: getFiles()
}
};
16 changes: 14 additions & 2 deletions grunt/uglify.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const concat = require('./concat');

function getFiles() {
const files = {};
const sources = Object.keys(concat.dist.files);

sources.forEach((srcFile) => {
files[srcFile.replace('.js', '.min.js')] = srcFile;
});

return files;
}

module.exports = {
options: {
banner: '<%= banner %>'
},
concat: {
src: '<%= concat.dist.dest %>',
dest: '<%= dist %>/release/<%= pkg.name %>.min.js'
files: getFiles()
}
};
4 changes: 3 additions & 1 deletion misc/tutorial/101_intro.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ Steps:
<li>Include uiGrid in your script and css
<pre>
<link rel="styleSheet" href="release/ui-grid.min.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular.min.js"></script>
<script src="/release/ui-grid.min.js"></script>
<!-- Or the following if you don't want to use all features -->
<!-- <script src="/release/ui-grid.base.min.js"></script> -->
</pre>
</li>
<li>Include ui.grid module as a dependency in your app
Expand Down
File renamed without changes.

0 comments on commit 6d26274

Please sign in to comment.