Skip to content

Commit

Permalink
Merge pull request #996 from Onlineberatung/OB-Theming
Browse files Browse the repository at this point in the history
feat: improved extension logic to be able to import original file in …
  • Loading branch information
web-mi authored Feb 12, 2024
2 parents a43c3a2 + 7b34aa1 commit c75a6da
Show file tree
Hide file tree
Showing 176 changed files with 5,271 additions and 4,514 deletions.
81 changes: 39 additions & 42 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,6 @@ const getTemplate = (templatePath) => {
return path.resolve(paths.appSrc, templatePath);
};

const localAliases = (paths) =>
paths
// Remove paths which are not overridden
.filter((localPath) => {
const fullPath = path.resolve(process.cwd(), `./${localPath}`);
try {
fs.statSync(fullPath);
return true;
} catch (error) {
return false;
}
})
.map(
(localPath) =>
new webpack.NormalModuleReplacementPlugin(
new RegExp(localPath),
path.resolve(process.cwd(), `./${localPath}`)
)
);

// This is the production and development configuration.
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
module.exports = function (webpackEnv) {
Expand Down Expand Up @@ -845,34 +825,51 @@ module.exports = function (webpackEnv) {
fs.existsSync(`${newPath}${originalExt}`) &&
!fs.lstatSync(`${newPath}${originalExt}`).isDirectory()
) {
console.log(
`Overwritten ${originalPath} -> ${newPath}${originalExt}`
);
// Skip override logic if issuer is itself
if (
result.contextInfo.issuer ===
`${newPath}${originalExt}`
) {
console.log(
`Self reference ${originalPath} -> ${newPath}${originalExt}`
);
return;
}

if (result.createData) {
result.createData.resource = `${newPath}${originalExt}`;
result.createData.context = path.dirname(
`${newPath}.${originalExt}`
console.log(
`Overwritten ${originalPath} -> ${newPath}${originalExt}`
);
result.request = result.request.replace(
originalPath,
`${newPath}${originalExt}`
);
result.context = path.dirname(
`${newPath}${originalExt}`
);
if (result.createData.request) {
result.createData.resource =
result.createData.resource.replace(
paths.appSrc,
paths.appExtensions
);
result.createData.request =
result.createData.request.replace(
originalPath,
`${newPath}`
);
result.createData.context = path.dirname(
`${newPath}${originalExt}`
);
}
} else {
console.log(
`No createData ${originalPath} -> ${newPath}${originalExt}`
);
}
}
}
),
...localAliases([
'src/resources/img/illustrations/answer.svg',
'src/resources/img/illustrations/arrow.svg',
'src/resources/img/illustrations/bad-request.svg',
'src/resources/img/illustrations/check.svg',
'src/resources/img/illustrations/consultant.svg',
'src/resources/img/illustrations/envelope-check.svg',
'src/resources/img/illustrations/internal-server-error.svg',
'src/resources/img/illustrations/not-found.svg',
'src/resources/img/illustrations/unauthorized.svg',
'src/resources/img/illustrations/waiting.svg',
'src/resources/img/illustrations/waving.svg',
'src/resources/img/illustrations/welcome.svg',
'src/resources/img/illustrations/x.svg'
])
)
].filter(Boolean),
// Turn off performance processing because we utilize
// our own hints via the FileSizeReporter
Expand Down
61 changes: 39 additions & 22 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash');
const { defineConfig } = require('cypress');

// @ts-ignore
Expand All @@ -20,25 +21,41 @@ const options = {
}
};

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:9001',
supportFile: 'cypress/support/e2e.{js,jsx,ts,tsx}',
setupNodeEvents(on, config) {
on('file:preprocessor', wp(options));
}
},
env: {
CYPRESS_WS_URL:
process.env.CYPRESS_WS_URL || process.env.REACT_APP_API_URL
},
retries: {
runMode: 2
},
video: false,
chromeWebSecurity: false,
viewportWidth: 1200,
viewportHeight: 800,
defaultCommandTimeout: 30000,
modifyObstructiveCode: false
});
let conf;
try {
conf = require('./src/extensions/cypress/cypress.json') || {};
} catch (e) {
console.log('No cypress.json file found, using default configuration');
conf = {};
}

module.exports = defineConfig(
_.mergeWith(
{
e2e: {
baseUrl: 'http://localhost:9001',
supportFile: 'cypress/support/e2e.{js,jsx,ts,tsx}',
setupNodeEvents(on, config) {
on('file:preprocessor', wp(options));
},
specPattern: ['cypress/e2e/**/*.cy.ts']
},
env: {
CYPRESS_WS_URL:
process.env.CYPRESS_WS_URL || process.env.REACT_APP_API_URL
},
retries: {
runMode: 2
},
video: false,
chromeWebSecurity: false,
viewportWidth: 1200,
viewportHeight: 800,
defaultCommandTimeout: 30000,
modifyObstructiveCode: false
},
conf,
(objValue, srcValue) =>
_.isArray(objValue) ? objValue.concat(srcValue) : undefined
)
);
Loading

0 comments on commit c75a6da

Please sign in to comment.