-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from christophercr/feature/basehref-docs
docs(stark-build): docs for base url and deploy url customization support
- Loading branch information
Showing
2 changed files
with
73 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Webpack Customizations | ||
|
||
Stark-Build uses several Webpack plugins as well as some utils in order to leverage lots of functionality and customizations to your builds (DEV and PROD). | ||
|
||
This is the list of utils and plugins used by the stark-build package: | ||
|
||
## Utils | ||
|
||
#### Support for custom base URL for assets | ||
|
||
Due to the possibility of defining a custom base url in your *index.html* thanks to the [BaseHrefWebpackPlugin](https://github.com/dzonatan/base-href-webpack-plugin "BaseHrefWebpackPlugin"), it is also necessary to customize the path of the different assets (images, styles, etc.). | ||
|
||
To do this, Stark uses the same custom logic implemented in the [@angular-devkit/build-angular](https://github.com/angular/devkit/blob/fe122511feada8d8c554799171e8e43bac950416/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/styles.ts "@angular-devkit/build-angular") to append the custom base url and the deploy url so you don't need to worry about the final path for every resource. | ||
|
||
The only thing you need to do is to configure the **baseHref** and **deployUrl** options (if needed) in the *angular.json* file as follows: | ||
|
||
```json | ||
{ | ||
... | ||
"projects": { | ||
"yourProjectName": { | ||
... | ||
"architect": { | ||
"yourTargetName": { | ||
... | ||
"options": { | ||
... | ||
"baseHref": "/some-url", // default value: "/" | ||
"deployUrl": "/some-url" // default value: "" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Plugins | ||
|
||
#### [BaseHrefWebpackPlugin](https://github.com/dzonatan/base-href-webpack-plugin "BaseHrefWebpackPlugin") | ||
Allows to customize the base url in the *index.html* via the webpack config. | ||
|
||
In Stark-Build, the custom base url provided to this plugin is the one you define in the **baseHref** option of your project's *angular.json* file: | ||
|
||
```json | ||
{ | ||
... | ||
"projects": { | ||
"yourProjectName": { | ||
... | ||
"architect": { | ||
"yourTargetName": { | ||
... | ||
"options": { | ||
... | ||
"baseHref": "/some-url" // default value: "/" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
This plugin will automatically add the base tag `<base href="<custom-base-url>">` to the *index.html* so you don't need to add it manually yourself. |
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