s-KaiNet / spfx-fast-serve

Improve your SharePoint Framework development flow by speeding up the "serve" command :rocket:
MIT License
133 stars 11 forks source link

Custom webpack config - DefinePlugin throws error "Cannot read properties of undefined (reading 'get' ) #99

Closed roldengarm closed 1 year ago

roldengarm commented 1 year ago

I'm trying to add a custom plugin to set some custom variables. In webpack.extend.js I've added:

const webpackConfig = {
  plugins: [new webpack.DefinePlugin({
    'VARIABLE': '"VALUE"'
  })]
}

However, getting an error at DefinePlugin.js: 292

compilation.valueCacheVersions.get(VALUE_DEP_MAIN)
"TypeError: cannot read properties of undefined (reading 'get')"

I appreciate you're busy, hopefully you can shed a light on this, thank you.

s-KaiNet commented 1 year ago

Usually with DefinePlugin, you should do JSON.stringify, i.e.:

const webpackConfig = {
  plugins: [new webpack.DefinePlugin({
    'VARIABLE': JSON.stringify('VALUE')
  })]
}
github-actions[bot] commented 1 year ago

This issue has been automatically closed because we haven't received any response back. Please feel free to reopen if needed.