diff --git a/webpack-prod.config.js b/webpack-prod.config.js index 363db00..e23761a 100644 --- a/webpack-prod.config.js +++ b/webpack-prod.config.js @@ -1,21 +1,32 @@ -var webpack = require('webpack'); -var path = require('path'); +const path = require('path'); +const pkg = require('./package.json'); -module.exports = { +const externals = new Set([ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), +]); + +const config = { entry: { - main: "./src/index.js", - Bootstrap: "./src/components/styled/Bootstrap.js", - Separate: "./src/components/separate/index.js", - AutocompleteField: "./src/components/AutocompleteField.jsx", - FormController: "./src/components/FormController.js" + main: './src/index.js', + Bootstrap: './src/components/styled/Bootstrap.js', + Separate: './src/components/separate/index.js', + AutocompleteField: './src/components/AutocompleteField.jsx', + FormController: './src/components/FormController.js', }, output: { path: path.join(__dirname, ''), - filename: "[name].js", - libraryTarget: "umd" + filename: '[name].js', + libraryTarget: 'umd', + }, + externals(context, request, callback) { + if (externals.has(request)) { + return callback(null, `${config.output.libraryTarget} ${request}`); + } + return callback(); }, resolve: { - extensions: ['.js', '.jsx'] + extensions: ['.js', '.jsx'], }, module: { rules: [ @@ -41,6 +52,8 @@ module.exports = { ] }, devServer: { - historyApiFallback: true - } -}; \ No newline at end of file + historyApiFallback: true, + }, +}; + +module.exports = config;