Skip to content

Commit

Permalink
Clear and build in tmp instead of dist
Browse files Browse the repository at this point in the history
* Increase file availability
* Tend to zero downtime deployment
  • Loading branch information
guillett committed Apr 20, 2018
1 parent ad428b2 commit ee9d5e3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -46,3 +46,5 @@ dist
.project
.sass-cache
.tmp

tmp
54 changes: 34 additions & 20 deletions Gruntfile.js
Expand Up @@ -19,12 +19,14 @@ module.exports = function (grunt) {

// Define the configuration for all the tasks
grunt.initConfig({

build: {
dist: 'dist',
},
// Project settings
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
dist: 'dist'
tmp: 'tmp'
},
express: {
options: {
Expand Down Expand Up @@ -94,12 +96,12 @@ module.exports = function (grunt) {

// Empties folders to start fresh
clean: {
dist: {
tmp: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*'
'<%= yeoman.tmp %>/*'
]
}]
},
Expand Down Expand Up @@ -162,7 +164,7 @@ module.exports = function (grunt) {
expand: true,
cwd: '<%= yeoman.app %>/styles',
src: '**/*.scss',
dest: 'dist/styles',
dest: '<%= yeoman.tmp %>/styles',
ext: '.css'
}],
options: {
Expand All @@ -176,9 +178,9 @@ module.exports = function (grunt) {
dist: {
files: {
src: [
'<%= yeoman.dist %>/js/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
'<%= yeoman.dist %>/styles/fonts/*'
'<%= yeoman.tmp %>/js/{,*/}*.js',
'<%= yeoman.tmp %>/styles/{,*/}*.css',
'<%= yeoman.tmp %>/styles/fonts/*'
]
}
}
Expand All @@ -190,15 +192,15 @@ module.exports = function (grunt) {
useminPrepare: {
html: ['<%= yeoman.app %>/views/front.html', '<%= yeoman.app %>/views/embed.html'],
options: {
dest: '<%= yeoman.dist %>'
dest: '<%= yeoman.tmp %>'
}
},

// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/views/{,*/}*.html'],
html: ['<%= yeoman.tmp %>/views/{,*/}*.html'],
options: {
assetsDirs: ['<%= yeoman.dist %>']
assetsDirs: ['<%= yeoman.tmp %>']
}
},

Expand All @@ -214,7 +216,7 @@ module.exports = function (grunt) {
expand: true,
cwd: '<%= yeoman.app %>/views',
src: ['**/*.html'],
dest: '<%= yeoman.dist %>/views'
dest: '<%= yeoman.tmp %>/views'
}]
}
},
Expand All @@ -234,12 +236,12 @@ module.exports = function (grunt) {

// Copies remaining files to places other tasks can use
copy: {
dist: {
tmp: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
dest: '<%= yeoman.tmp %>',
src: [
'*.{ico,png,txt}',
'bower_components/**/*',
Expand All @@ -252,9 +254,20 @@ module.exports = function (grunt) {
}, {
expand: true,
cwd: '.tmp/img',
dest: '<%= yeoman.dist %>/img',
dest: '<%= yeoman.tmp %>/img',
src: ['generated/*']
}]
},
dist: {
files: [{
expand: true,
dot: true,
cwd: 'tmp',
dest: 'dist',
src: [
'**/*'
]
}]
}
},

Expand Down Expand Up @@ -297,8 +310,8 @@ module.exports = function (grunt) {

htmlrefs: {
dist: {
src: './dist/views/front.html',
dest: './dist/views/front.html'
src: './<%= yeoman.tmp %>/views/front.html',
dest: './<%= yeoman.tmp %>/views/front.html'
}
}
});
Expand Down Expand Up @@ -341,17 +354,18 @@ module.exports = function (grunt) {
]);

grunt.registerTask('build', [
'clean:dist',
'clean:tmp',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngAnnotate',
'copy:dist',
'copy:tmp',
'uglify',
'rev',
'usemin',
'htmlrefs:dist'
'htmlrefs:dist',
'copy:dist'
]);

grunt.registerTask('default', [
Expand Down

0 comments on commit ee9d5e3

Please sign in to comment.