Skip to content

Commit

Permalink
fix(build): Fix webpack externals config to use correct package names…
Browse files Browse the repository at this point in the history
… in CJS environments, closes #9
  • Loading branch information
zenflow committed Mar 7, 2018
1 parent 29afef7 commit 1063416
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"react-dom": "^16.2.0",
"semantic-release": "^15.0.0",
"sweetalert2": "^7.15.1",
"webpack": "^4.1.0",
"webpack": "^4.1.1",
"webpack-serve": "^0.1.5"
},
"eslintConfig": {
Expand Down
17 changes: 15 additions & 2 deletions webpack.config.dist.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
/* eslint-env node */
const path = require('path')

function expandExternalsConfig(compactConfig) {
const expandedConfig = {}
for (const packageName of Object.keys(compactConfig)) {
expandedConfig[packageName] = {
commonjs: packageName,
commonjs2: packageName,
amd: packageName,
root: compactConfig[packageName],
}
}
return expandedConfig
}

module.exports = {
mode: 'production',
devtool: 'source-map',
entry: [require.resolve('./src/main')],
externals: {
externals: expandExternalsConfig({
react: 'React',
'react-dom': 'ReactDOM',
sweetalert2: 'swal',
},
}),
output: {
library: 'sweetalert2ReactContent',
libraryTarget: 'umd',
Expand Down

0 comments on commit 1063416

Please sign in to comment.