Giter Site home page Giter Site logo

Comments (3)

MichaelSitter avatar MichaelSitter commented on May 24, 2024

@iDVB the issue name is misleading; these are called template strings in the grunt documentation: http://gruntjs.com/api/grunt.template

But yeah, I'm having the same problem. Config settings work file because they are actually parsed by grunt and compiled, but if you think about it the webpack plugins have no idea they are being consumed by grunt. So the template replacements would never happen.

from grunt-webpack.

nwoltman avatar nwoltman commented on May 24, 2024

This is not a bug. As @MichaelSitter mentioned, grunt does not have access to anything passed to a plugin's constructor, so it can't process template strings passed to plugins.

If you really want to use grunt's template strings in this manner, here is a potential workaround:

new HtmlWebpackPlugin({
  get gitHash() {
    return grunt.template.process('<%= gitinfo.local.branch.current.shortSHA %>')
  },
  template: 'index.html', // Load a custom template 
  inject: false
})

from grunt-webpack.

knightcode avatar knightcode commented on May 24, 2024

Adding another example here since this issue was the solution I was looking for:

new webpack.DefinePlugin({
  "process.env": {
   get DEPLOY_VERSION() {
      return grunt.template.process("'?v=<%= DEPLOY_VERSION %>'")
    }
  }
})

I'm able to call grunt.config("DEPLOY_VERSION", val) from another grunt task each iteration of grunt watch to bust my browser cache.

from grunt-webpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.