la commande principale étant : php bin/console assets:install
1 - générer les assets à chaque modification de fichiers dans :
src/AppBundle/Resources/public
Se servir de grunt (nodes_modules) dans le répertoire de l'application.
1 - Installer les modules
npm install grunt-shell --save-dev (pour exécuter la commande php bin/console assets:install
npm install grunt-contrib-watch --save-dev (pour surviller le repertoire des assets)
2 - mettre en place le script suivant
module.exports = function(grunt) {
grunt.initConfig({
baseURL: "src/AppBundle/Resources/public",
shell: {
clearCache: {
options: {
stdout: true
},
command: 'php bin/console cache:clear'
},
assetsInstall: {
options: {
stdout: true
},
command: 'php bin/console assets:install'
}
},
watch: {
options: {
dateFormat: function(time) {
grunt.log.writeln("The watch finished in " + time + "ms at" + (new Date()).toString());
grunt.log.writeln("Waiting for more changes...");
}
},
branchChanged: { // clear cache if the branch is changed
files: '.git/HEAD',
tasks: ['shell:clearCache'],
options: {
spawn: true
}
},
scripts: {
files: ['<%= baseURL %>/**/*.js',
'<%= baseURL %>/**/*.css',
'<%= baseURL %>/**/*.sass',
'<%= baseURL %>/**/*.scss',
'<%= baseURL %>/**/*.less',
'<%= baseURL %>/**/*.png',
'<%= baseURL %>/**/*.svg',
'<%= baseURL %>/**/*.gif',
'<%= baseURL %>/**/*.jpg',
'<%= baseURL %>/**/*.jpeg',
'<%= baseURL %>/**/*.map',
'<%= baseURL %>/**/*.twig'],
tasks: ['shell:assetsInstall'],
options: {
interrupt: true
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-shell");
grunt.registerTask("default", ['shell:assetsInstall']);
grunt.registerTask("assets install", "A task to install assets.", function() {
grunt.task.run("shell:assetsInstall");
});
grunt.registerTask("all", "A task to dump all assets and clear cache.", function() {
grunt.task.run("shell:clearCache");
grunt.task.run("shell:assetsInstall");
});
grunt.registerTask("setDir", "A task to set the web dir of the project.", function() {
grunt.config.set("dir", "web/bundles/app");
grunt.log.writeln("DIR: " + grunt.config.get("dir"));
grunt.log.writeln("BASE_URL: " + grunt.config.get("baseURL"));
});
console.info("BASE_URL: " + grunt.config.get("watch").scripts.files[0]);
grunt.task.run(['setDir']);
};
3 - ouvrir une console et se placer dans l'application
et lancer la commande grunt watch
- source web doc
grunt watch + symfony