Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Add module aliases #517

Merged
merged 3 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/webpack/alias-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ module.exports = {
alias['@blackbaud/skyux/dist'] = spaPath(skyPagesConfig.skyux.importPath);
}

// Allow SPAs to provide custom module aliases.
const moduleAliases = skyPagesConfig.skyux.moduleAliases;
if (moduleAliases) {
Object.keys(moduleAliases).forEach((key) => {
alias[key] = spaPath(moduleAliases[key]);
});
}

setSpaAlias(
alias,
'src/app/app-extras.module',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@skyux-sdk/pact": "3.0.1",
"@skyux-sdk/testing": "3.0.0",
"@skyux/assets": "3.0.0",
"@skyux/config": "3.3.0",
"@skyux/config": "3.5.0",
"@skyux/http": "3.2.0",
"@skyux/i18n": "3.5.0",
"@skyux/omnibar-interop": "3.1.0",
Expand Down
17 changes: 17 additions & 0 deletions test/config-webpack-common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,21 @@ describe('config webpack common', () => {
expect(plugin.calls.first().args[0].color).toEqual(true);
});

it('should allow for custom alias resolution', () => {
const lib = mock.reRequire('../config/webpack/common.webpack.config');

const config = lib.getWebpackConfig({
runtime: runtimeUtils.getDefaultRuntime(),
skyux: {
moduleAliases: {
'@skyux/foo': './src/app/public'
}
}
});

const alias = config.resolve.alias;

expect(alias['@skyux/foo']).toBe(path.join(process.cwd(), './src/app/public'));
});

});