brunodd brunodd - 1 year ago 120
Javascript Question

Grunt uglify - Update src after combining files

I am combining all my js files for production using

but after combining them and generating my final
file, how I can update the
script src

The index file should have only one
tag with
but instead its pointing to all sources that I used on develop mode.

uglify: {
options: {
mangle: false
all: {
files: [{
expand: true,
cwd: 'dev/assets/js',
src: ['*.js', '**/*.js'],
dest: 'prod/assets/js'
my_target: {
files: {
'prod/js/app.min.js' : ['prod/assets/js/**/*.js']

Answer Source

Take a look at the node package 'grunt-processhtml'. It will update the source links in your html file.

<!-- build:js app.min.js -->
<script src="my/lib/path/lib.js"></script>
<script src="my/deep/development/path/script.js"></script>
<!-- /build -->

<!-- changed to -->
<script src="app.min.js"></script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download