Comments (4)
Are you using the proxy
option to alter the requests or are you using a custom builder via programmatic usage of the development server builder?
Would it be possible to provide an example of what you are attempting?
from angular-cli.
We're using custom builder to pass additional middleware.
At this moment excerpt from our middleware config looks like this:
themeAssets.map(
(asset: string): NextHandleFunction =>
function (req, res, next) {
if (req.url?.includes(`/assets/${asset}`)) {
const theme = parseThemeName(req)
if (theme) {
res.writeHead(302, {
location: `/assets/context/${theme}/${asset}`,
})
res.end()
return
}
}
next()
},
)
themeAssets
is an array of assets (logo.png
, etc.),parseThemeName
extracts desired theme from the url.
We'd like to use the same approach for css
files (for example, we want redirect theme-default.css
to theme-XYZ.css
when needed. Currently this is not possible, because custom middlewares are not executed for css
files at all.
from angular-cli.
Ideally, this should be possible with a customized proxy configuration file. I'll see if I can put together an example.
Are you using the customized builder for anything beyond the additional middleware?
from angular-cli.
Ideally, this should be possible with a customized proxy configuration file.
It seems to work for images or other static assets, but doesn't for CSS files.
I've even tried to "catch-all" requests with:
export default {
'/': {
bypass: function (req, res, proxyOptions) {
console.log(req.url)
},
},
}
When you visit localhost:4200/theme-default.css
, only url containing favicon.ico
is being logged.
When you visit localhost:4200/asset/header-logo.png
, request is correctly intercepted and I can redirect it wherever I need.
Are you using the customized builder for anything beyond the additional middleware?
Yes, we also provide some esbuild plugins - mostly to replace some placeholders (using options.define
).
from angular-cli.
Related Issues (20)
- ng build with the --watch flag applied makes it difficult to `npm link` as the the package version numbers dynamically change HOT 4
- `application` builder fails to load imports with *?worker when prebudling is set to false. HOT 1
- Angular 17 custom library issue HOT 1
- Angular 17: getting Internal server error: Invalid URL error when starting dev server HOT 1
- @angular-devkit/build-angular depends on vulnerable version of webpack-dev-middleware HOT 10
- Production mode doesn't transform RegEx correctly HOT 3
- Is It Possible to Dynamically Select a Proxy Server When Serving an Application? HOT 1
- Debugging doesn't work in Visual Studio Code after upgrade to angular v17 with browser-esbuild builder
- Debugging doesn't work in Visual Studio Code after upgrade to angular v17 with browser-esbuild builder HOT 2
- vunerability in webpack-dev-middleware HOT 1
- output-hashing in angular 17 (prerender mode) does not work HOT 1
- The relative path image in the scss file is not added with base-href after ng build. HOT 4
- stylePreprocessorOptions.includePath is not following symlinks when using @angular-devkit/build-angular:application
- Support lazy loading imports in html template HOT 1
- Angular 17 SSR baseHref / baseUrl is not respected
- ng add @nguniversal/[email protected] is installing the package but, not creating the server files like server.ts. Getting error HOT 1
- npm install hangs forever and freezing rancher desktop while dockerizing angular application HOT 1
- Types disappearing (or heavily simplified) if not using `npm link` HOT 4
- Angular 17 prerender performance mark has not been set HOT 1
- Cannot import mapbox worker with application builder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-cli.