Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
updated webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
sdadn committed May 7, 2024
1 parent dc0ddb0 commit 0493993
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
43 changes: 22 additions & 21 deletions packages/terra-dev-site/src/webpack/plugin/SitePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const chalk = require('chalk');
// const http = require('http');

const DirectorySwitcherPlugin = require('./resolve/DirectorySwitcherPlugin');
// const LocalPackageAliasPlugin = require('./resolve/LocalPackageAliasPlugin');
const LocalPackageAliasPlugin = require('./resolve/LocalPackageAliasPlugin');
// const LocalSubpathExportsResolverPlugin = require('./resolve/LocalSubpathExportsResolverPlugin');
const { babelLoader, getMdxLoader } = require('./siteLoaderUtils');
const getNewRelicJS = require('../new-relic/getNewRelicJS');
Expand All @@ -29,12 +29,17 @@ const urlQueue = [];
* Updates the webpack options with defaults that terra-dev-site requires.
*/
class SitePlugin {

Check failure on line 31 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines
constructor({
entry,
config,
}) {

static siteConfig2 = {};

constructor({ entry, config }) {
// Apply defaults to the config.

this.siteConfig2 = config;
this.siteConfig = config;

console.log(this.siteConfig2.disableDefaultResolver);

Check warning on line 41 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

const { pathPrefix, titleConfig } = this.siteConfig;
this.entry = entry;

Expand Down Expand Up @@ -68,6 +73,7 @@ class SitePlugin {
distributionFolder,
basename,
isWebpack5,
disableDefaultResolver

Check failure on line 76 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

Missing trailing comma
}) {
if (oneTimeSetupComplete) {
return;
Expand All @@ -86,6 +92,8 @@ class SitePlugin {
...isLernaMonoRepo ? [path.resolve(processPath, 'packages', '*')] : [processPath],
];

console.log("static", disableDefaultResolver);

Check warning on line 95 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

Check failure on line 95 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

let webpackConfig = {
entry: {
rewriteHistory: '@cerner/terra-dev-site/lib/browser-router-redirect/rewriteHistory',
Expand All @@ -97,10 +105,7 @@ class SitePlugin {
// Only the first loader will apply and no others.
oneOf: [{
test: /\.mdx$/,
use: [
babelLoader,
mdxLoader,
],
use: [ babelLoader, mdxLoader ],

Check failure on line 108 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

There should be no space after '['

Check failure on line 108 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

There should be no space before ']'
}, {
test: /\.md$/,
oneOf: [
Expand Down Expand Up @@ -135,19 +140,13 @@ class SitePlugin {
],
}, {
resourceQuery: '?dev-site-example',
use: [
babelLoader,
'devSiteExample',
],
use: [ babelLoader, 'devSiteExample' ],

Check failure on line 143 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

There should be no space after '['

Check failure on line 143 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

There should be no space before ']'
}, {
test: /\.json$/,
// this bypasses the default json loader
type: 'javascript/auto',
resourceQuery: '?dev-site-package',
use: [
babelLoader,
'devSitePackage',
],
use: [ babelLoader, 'devSitePackage' ],

Check failure on line 149 in packages/terra-dev-site/src/webpack/plugin/SitePlugin.js

View workflow job for this annotation

GitHub Actions / build

There should be no space after '['
}, {
resourceQuery: '?dev-site-props-table',
use: [
Expand Down Expand Up @@ -188,9 +187,10 @@ class SitePlugin {
}),
]
: [],
// new LocalSubpathExportsResolverPlugin({rootDirectories}),
// // Alias the local package to allow imports to reference the file as if it was imported from node modules.
// new LocalPackageAliasPlugin({rootDirectories}),
// ...(this.siteConfig2.disableDefaultResolver? [] : [new LocalSubpathExportsResolverPlugin({rootDirectories})]),

// // Alias the local package to allow imports to reference the file as if it was imported from node modules.
...(disableDefaultResolver? [] : [new LocalPackageAliasPlugin({rootDirectories})]),
],
},
// add the path to search for dev site loaders
Expand Down Expand Up @@ -269,7 +269,7 @@ class SitePlugin {
// Strip the trailing / from the public path.
let basename = publicPath.slice(0, -1);

const { sourceFolder, distributionFolder } = this.siteConfig;
const { sourceFolder, distributionFolder, disableDefaultResolver } = this.siteConfig;

// Since there can be multiple dev site plugins this config we only want to do once for all of them.
SitePlugin.applyOneTimeSetup({
Expand All @@ -278,6 +278,7 @@ class SitePlugin {
distributionFolder,
basename,
isWebpack5,
disableDefaultResolver
});

// Get the list of apps excluding this current app.
Expand Down
2 changes: 2 additions & 0 deletions packages/terra-dev-site/src/webpack/plugin/applyDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const applyDefaults = ({
defaultLocale,
defaultTheme,
defaultDirection,
disableDefaultResolver = false,
faviconFilePath = path.join(__dirname, '..', 'terra-favicon', '32px', 'favicon.ico'),
extensionItems = [],
headHtml = [],
Expand All @@ -69,6 +70,7 @@ const applyDefaults = ({
defaultLocale,
defaultTheme,
defaultDirection,
disableDefaultResolver,
faviconFilePath,
extensionItems,
headHtml,
Expand Down
8 changes: 5 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ const TerraDevSite = require('./packages/terra-dev-site/src/webpack/plugin/Terra

const html = fs.readFileSync(require.resolve('./tests/terra-dev-site/head.html'), 'utf8');


Check warning on line 9 in webpack.config.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
// WebpackConfigTerra.plugins;

const devSiteConfig = (env = {}, argv = { p: false }) => ({
// temporary fix to enable live reloading.
target: argv.p || argv.mode === 'production' ? 'browserslist' : 'web',
plugins: [
new TerraDevSite({
disableDefaultResolver: true,
defaultLocale: env.defaultLocale,
excludeChunks: ['terra-application-test/index'],
}),
new TerraDevSite({
disableDefaultResolver: true,
pathPrefix: 'extended',
contentDirectory: 'dev-site-extended-test',
primaryNavigationItems: [{
Expand Down Expand Up @@ -85,9 +90,6 @@ const devSiteConfig = (env = {}, argv = { p: false }) => ({
alias: {
'terra-application/package.json': path.resolve(__dirname, 'packages', 'terra-application', 'package.json')
},
modules: [path.resolve(__dirname, 'packages'), 'node_modules'],
exportsFields: ['exports'],
mainFiles: ['index'],
extensions: ['.jst', '.jsx', '.js'],
},
});
Expand Down

0 comments on commit 0493993

Please sign in to comment.