Luismahou / grunt-hashres

Hashes your js and css files and rename the <script> and <link> declarations that refer to them in your html/php/etc files.
MIT License
115 stars 41 forks source link

Can't get it working with requirejs #54

Closed TrangNguyen closed 9 years ago

TrangNguyen commented 9 years ago

Hi, I can't get grunt-hashres to work together with Requirejs. My index.html has if build and if local conditions, like this

<!--(if target build)>
<link rel="stylesheet" type="text/css" href="css/app.css">
<script src="modules/main.js" data-main="main"></script>
<!(endif)-->

 <!--(if target local)> -->
 <!--<script type="text/javascript">parent.uitest && parent.uitest.instrument(window);</script>-->
 <link rel="stylesheet" type="text/css" href="css/app.css">
 <script src="http://localhost:35729/livereload.js"></script>
 <script src="../../bower_components/requirejs/require.js" data-main="modules/main"></script>
 <!--<!(endif)-->

in my gruntfile.js I compiled, minified css and js before hashres them, like this

hashres: {
      options: {
        encoding: 'utf8',
        fileNameFormat: '${name}.${hash}.cache.${ext}',
        renameFiles: true
      },
      prod: {
        src: [
          '<%= pkg.folders.build + pkg.name + "-" + pkg.version %>/modules/main.js',
          '<%= pkg.folders.build + pkg.name + "-" + pkg.version %>/css/app.css'],
        dest: '<%= pkg.folders.build + pkg.name + "-" + pkg.version %>/index.html'
      }
}

I saw that the files got hashed names

Running "hashres:prod" (hashres) task
target/veryInk-0.0.8/modules/main.js >> main.56f70f33.cache.js
target/veryInk-0.0.8/css/app.css >> app.56895787.cache.css

but the index.html is not updated, so of course it can't find the referenced css and js. Any hint would be greatly appreciated. Trang.

TrangNguyen commented 9 years ago

It seemed to be in conflict in running with grunt-sftp-deploy. If I turned grunt-sftp-deploy off, it works nicely. I made the task that runs sftp-deploy requires the other tasks that run hashres now so thanks for a nice module.