Skip to content

Commit

Permalink
consume webpack-config-terra package (cerner#3191)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhenkes authored Oct 14, 2020
1 parent cd74576 commit 8c11153
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = (api) => {
api.assertVersion('^7.4.4');

const presets = [
'@babel/preset-env',
['@babel/preset-env', { useBuiltIns: 'entry', corejs: { version: 3.6, proposals: true } }],
'@babel/preset-react',
];
const plugins = [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"@babel/preset-react": "^7.0.0",
"@cerner/browserslist-config-terra": "^3.1.0",
"@cerner/eslint-config-terra": "^4.0.0",
"@cerner/webpack-config-terra": "^1.0.0-alpha.0",
"babel-jest": "^24.8.0",
"check-installed-dependencies": "^1.0.0",
"core-js": "^3.1.3",
Expand Down
33 changes: 30 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
const path = require('path');
const merge = require('webpack-merge');
const defaultWebpackConfig = require('terra-dev-site/config/webpack/webpack.config');
const {
TerraDevSite,
TerraDevSiteEntrypoints,
DirectorySwitcherPlugin,
LocalPackageAliasPlugin,
} = require('terra-dev-site');

const coreConfig = () => {
const WebpackConfigTerra = require('@cerner/webpack-config-terra');

const coreConfig = (env = {}, argv = { p: false }) => {
const production = argv.p;
const processPath = process.cwd();
const rootPath = processPath.includes('packages') ? processPath.split('packages')[0] : processPath;

const i18nAlias = path.resolve(path.join(rootPath, 'packages', 'terra-i18n'));
return {
entry: TerraDevSiteEntrypoints,
plugins: [
new TerraDevSite({ env }),
],
resolve: {
plugins: [
new DirectorySwitcherPlugin({
shouldSwitch: !production,
rootDirectories: [
processPath,
path.resolve(processPath, 'packages', '*'),
],
}),
new LocalPackageAliasPlugin({
rootDirectories: [
processPath,
path.resolve(processPath, 'packages', '*'),
],
}),
],
alias: {
'terra-i18n': i18nAlias,
},
Expand All @@ -17,7 +44,7 @@ const coreConfig = () => {
};

const mergedConfig = (env, argv) => (
merge(defaultWebpackConfig(env, argv), coreConfig())
merge(WebpackConfigTerra(env, argv), coreConfig())
);

module.exports = mergedConfig;

0 comments on commit 8c11153

Please sign in to comment.