-
-
Notifications
You must be signed in to change notification settings - Fork 69
Modified move/copy behaviour to enable a user choice. #27
Conversation
Test passed with success, would you consider integrating this pull request within the actual module? |
Why wouldn't you just provide a dest? |
Simply because my dest is the same as my cwd. files: {
expand: true,
cwd: 'dist',
dest: 'dist',
// Note: index.html and admin.html must not be prefixed.
src: ['**/*.html', '!{index,admin}.html', 'images/*', 'scripts/{,controllers/,services/}*.js', 'styles/*.css', 'i18n/*.json'],
filter: 'isFile'
} |
How do you handle things like version control? Why are they the same directory? I am curious about different workflows. |
###Project looks like this: ###Build cycle
I am curious and open to suggestions if you have any better idea in terms of workflow. Thanks for your input |
is there merely to have minified and unminified, built files in the same directory? |
Yes basically, in the styles folder for instance, we will have some css files moved from the original directory, plus the compiled css from sass. Now that both of them are in the same directory, we will add revisions to all of them. my workflow basically moves the resources one by one so they can get computed globally with whatever is in the dist folder at one instant. It will only work if I move resources, because today it copies them and I have two versions of each file in dist (one minified, the other not) |
now I am totally confused by what you are trying to accomplish |
I guess there's no other way than sharing the Gruntfile, it will be easier. //Cleaning task
clean: {
all: ['dist', '.tmp'],
tmp: ['.tmp']
webapp: [
'../trainout-webservices/src/main/webapp/bower_components',
'../trainout-webservices/src/main/webapp/i18n',
'../trainout-webservices/src/main/webapp/scripts',
'../trainout-webservices/src/main/webapp/styles',
'../trainout-webservices/src/main/webapp/views',
'../trainout-webservices/src/main/webapp/*.html'
]
},
//Copy task
copy: {
dist: {
expand: true,
cwd: "app",
src: [
'**',
'!styles/sass/**',
'!bower_components/**',
'!scripts/**/*.js',
'[**, !bower_components]/*.html',
'images/*'
],
dest: "dist"
},
assets: {
expand: true,
src: ['bower_components/**','bower.json'],
dest: "dist"
},
debug: {
cwd: "app",
expand: true,
src: ['**', '!styles/sass/**'],
dest: "dist"
}
},
//SCSS Compile task
sass: {
files: // Put compiled css in .tmp/styles
{
expand: true,
cwd: "app/styles/sass",
src: "**/*.scss",
dest: ".tmp/styles",
ext: '.css'
}
},
//CSS Minify task
cssmin: {
files: // Minify css to dist/ destination
{
expand: true,
cwd: ".tmp/styles",
src: "**/*.css",
dest: "dist/styles"
}
},
//JSON Minify task
'json-minify': {
build: {
files: 'dist/i18n/**/*.json'
}
},
//Javascript minify task
uglify: {
dist: {
expand: true,
cwd: 'app',
src: ['scripts/**/*.js'],
dest: 'dist'
}
},
//Add revision prefix
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 8,
keepOriginalFiles: false
},
files: {
expand: true,
cwd: 'dist',
dest: 'dist',
// Note: index.html and admin.html must not be prefixed.
src: ['**/*.html', '!{index,admin}.html', 'images/*',
'scripts/{,controllers/,services/}*.js', 'styles/*.css', 'i18n/*.json'],
filter: 'isFile'
}
},
//Update old files matches to new ones
usemin: {
html: 'dist/**/*.html',
css: 'dist/**/*.css',
// Custom matchings
htmlextra: 'dist/**/*.html',
js: 'dist/scripts/{,controllers/,services/}*.js',
options: {
patterns: {
htmlextra: [
[/src="'([^"']+)'"/gm,
"Update the HTML angular includes with new HTML filenames"]
],
js: [
[/['"]([^"']+)["']/gm,
'Update the JS with the new HTML filenames']
]
}
}
},
//Bower install task
bowerInstall: {
target: {
// Files updated when running bower install
src: [
'**/*.html' // .html support...
],
cwd: "dist"
}
},
//Connect task
connect: {
options: {
port: 9000,
livereload: 32323,
hostname: 'localhost'
},
livereload: {
options: {
open: 'localhost',
base: ['dist']
}
}
},
//Watch task
watch: {
app: {
files: ['app/**'],
tasks: ['default'],
options: {
reload: true
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-filerev');
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-json-minify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-bower-install');
// Default task.
grunt.registerTask('default', ['clean:all', 'copy:dist', 'sass',
'cssmin', 'json-minify', 'uglify', 'filerev', 'usemin', 'copy:assets',
'bowerInstall', 'clean:tmp']);
// Serve task.
grunt.registerTask('serve', function () {
grunt.task.run(['default', 'connect', 'watch']);
}); |
isn't #21 a simpler way to achieve the same? |
Exactly the same feature, I like the "copy" option better, however the algorithm he used could still be improved a little. |
It's nearly the same feature: in #21 the choice whether files are copied or moved is entirely controlled by the flag (if the flag is set to |
Yes, you are absolutely right :) |
I'm going to close this in favor of #21. @loicortola if you feel that is missing something, please ask for it there or suggest fixes. Thanks though |
In my build flow, I came with the following issue:
I specified a dest folder, but still needed to move the resources (instead of making a copy)
This behaviour is now implemented in a few lines, in a non regressive way. A user now simply needs to override the keepOriginalFiles option to false if he wants to use this feature.