-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f967cd
commit d895c3f
Showing
8 changed files
with
69 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
module.exports = class Alias { | ||
const { Component } = require('./Component'); | ||
|
||
module.exports = class Alias extends Component { | ||
/** @type {Record<string, string>} */ | ||
aliases = {}; | ||
|
||
/** | ||
* Add resolution aliases to webpack's config | ||
* | ||
* @param {Record<string,string>} paths | ||
* @param {Record<string, string>} paths | ||
*/ | ||
register(paths) { | ||
/** @type {Record<string, string>} */ | ||
this.aliases = { ...(this.aliases || {}), ...paths }; | ||
this.aliases = { ...this.aliases, ...paths }; | ||
} | ||
|
||
webpackConfig(webpackConfig) { | ||
webpackConfig.resolve.alias = webpackConfig.resolve.alias || {}; | ||
/** | ||
* | ||
* @param {import('webpack').Configuration} config | ||
*/ | ||
webpackConfig(config) { | ||
config.resolve = config.resolve || {}; | ||
config.resolve.alias = config.resolve.alias || {}; | ||
|
||
for (const [alias, path] of Object.entries(this.aliases)) { | ||
webpackConfig.resolve.alias[alias] = Mix.paths.root(path); | ||
config.resolve.alias[alias] = this.mix.paths.root(path); | ||
} | ||
|
||
return config; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters