pirelenito / git-revision-webpack-plugin

🏗 Webpack plugin that generates VERSION and COMMITHASH files during build
https://www.npmjs.com/package/git-revision-webpack-plugin
MIT License
358 stars 48 forks source link

Cant eaccess prototype functions in code #13

Closed wdunn001 closed 7 years ago

wdunn001 commented 7 years ago

when I try to use 'VERSION': JSON.stringify(GitRevisionPlugin.version()) I get the following response Inner Exception 1: Exception: Call to Node module failed with error: TypeError: GitRevisionPlugin.version is not a function I am using the code like this

new webpack.DefinePlugin({ 'process.env': { 'ENV': JSON.stringify(isDevBuild ? 'Development' : 'Production'), 'VERSION': JSON.stringify(GitRevisionPlugin.version()) } })

new GitRevisionPlugin() does work on its own and writes the files.

pirelenito commented 7 years ago

Hi, to get access to those functions, you must create an instance of the plugin as documented:

var gitRevisionPlugin = new GitRevisionPlugin()

module.exports = {
  plugins: [
    gitRevisionPlugin,
    new webpack.DefinePlugin({ 'process.env': { 'ENV': JSON.stringify(isDevBuild ? 'Development' : 'Production'), 'VERSION': JSON.stringify(gitRevisionPlugin.version()) } })
  ]
}

The idea being that you would share the instance with webpack.

Cheers,

pirelenito commented 7 years ago

I'm closing this issue.

Let me know if you need anything else.

wdunn001 commented 7 years ago

oh lord I totally missed that thank you! I think i just glossed over it thinking it was the require...