Imagine having an exported function called createTableFromJSON(json)
from the main file named index.js
. The configuration example below adheres to the guidelines outlined in Webpack's official documentation:
const config = {
entry: './assets/javascripts/index.js',
output: {
library: {
name: 'HotchPotch',
type: 'global'
},
libraryTarget: 'var',
path: path.resolve(__dirname, 'static'), // Should be in STATICFILES_DIRS
publicPath: '/static/', // Should match Django's STATIC_URL
// filename: '[name].js', // No filename hashing, Django takes care of this
filename: 'main.js',
// chunkFilename: '[id]-[chunkhash].js', // DO have Webpack hash chunk filename
clean: true
},
The issue arises when expected function exports do not appear as intended. Furthermore, HotchPotch
is identified as undefined
. How can this configuration problem be resolved?