Given an exported funtion createTableFromJSON(json)
from the entry file index.js
and this config example that follows the specifications given on the official Webpack wiki :
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
},
Function exports would be expected to appear, but are not. HotchPotch
also is logged as being undefined
. What's the issue with this configuration?
I figured out that accessing an exported method through the variable global
is needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.