Skip to content

Commit

Permalink
Add custom src alias support
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkellys committed Oct 21, 2023
1 parent 9d7a48e commit e24fea8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ At the root of your project, create a `rebuiltron.config.js` file.
| --- | :---: | :---: | --- |
| `renderers` | `object` || Renderer entries. It takes the name of the entries as keys and their paths as values. |
| `preloads` | `object` || Preload entries. It takes the name of the entries as keys and their paths as values. |
| `sassOptions` | `object` || Custom SASS options for `sass-loader`. |
| `sassOptions.additionalData` | `object` |* | Configuration of `additionalData`. |
| `srcAlias` | `string` | ✗ | Custom [alias](https://webpack.js.org/configuration/resolve/#resolvealias) to the `src` folder.
| `sassOptions` | `object` || Custom SASS options for [`sass-loader`](https://github.com/webpack-contrib/sass-loader). |
| `sassOptions.additionalData` | `object` |* | Configuration of [`additionalData`](https://webpack.js.org/loaders/sass-loader/#additionaldata). |
| `sassOptions.additionalData.data` | `string` |* | Data to prepend to SASS files. |
| `sassOptions.additionalData.exclude` | `Regex` |* | Regex matching the files to exclude from `additionalData`. This is necessary to prevent an `@import loop` error. |

Expand All @@ -105,12 +106,13 @@ At the root of your project, create a `rebuiltron.config.js` file.
```js
module.exports = {
renderers: {
index: "./src/index.js",
app: "./src/app.js",
worker: "./src/worker.js"
},
preloads: {
worker: "./electron/preloads/worker.js"
},
srcAlias: "@app",
sassOptions: {
additionalData: {
data: "@use \"styles/settings\" as *;",
Expand Down
10 changes: 7 additions & 3 deletions configurations/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const javascriptLoaders = require("../loaders/javascript");
const rebuiltronConfig = require("../rebuiltronConfig");


const { srcAlias } = require(paths.appConfig);

module.exports = {
stats: "errors-warnings",
bail: isEnvProduction,
Expand All @@ -43,9 +45,11 @@ module.exports = {
resolve: {
modules: ["node_modules", paths.appNodeModules, paths.appSrc],
extensions: [".web.js", ".js", ".json", ".jsx", ".node"],
alias: {
src: paths.appSrc
}
...emptyOr(srcAlias, {
alias: {
[srcAlias]: paths.appSrc
}
})
},
optimization: {
minimize: isEnvProduction,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rebuiltron",
"version": "1.0.3",
"version": "2.0.0",
"author": "Arkellys",
"license": "MIT",
"bin": {
Expand Down

0 comments on commit e24fea8

Please sign in to comment.