Reputation: 1587
I am using lite-server to help with the development of ng2 apps (to which I am new). It refreshes my index.html in the browser whenever changes are made in the project.
But what in the case where I'm dealing with index.php? Before I'd serve it through my LAMP stack.
How can I combine the ease of use of lite-server when developing ng2 apps with the need for php compilation? Is there some configuration that I can adjust in lite-server for it to launch a different URL for instance (that points to apache instead of localhost:3000)? I checked the readme, but it doesn't mention something like this, nor can I find something with a google search.
Upvotes: 3
Views: 2126
Reputation: 33
I don't know if can help, but I added too:
files: [
"*","*.*","**"
]
because browserSync was missing whatching php files.
So, in general, my bs-config.js file looks like:
module.exports = {
files: [
"*","*.*","**"
],
server: {
middleware: {
1: require('connect-modrewrite')(['^/$ http://localhost/testing/angular2/index.php [P]'])
}
}
};
where http://localhost/ is my wamp server and testing/angular2/ my folder location, the same in which launch the lite-server
Upvotes: 0
Reputation: 5730
updated answer
I updated the answer, because it is not working as expected with the proxy-middleware. I tried the connect-modrewrite instead, which is working as expected.
First, you need to install the middleware like this:
npm install connect-modrewrite --save-dev
Then you can add the rule like this in your browserSync config:
middleware : [
require('connect-modrewrite')([
`^/$ ${BACKEND_HOST}${BACKEND_URI}index.php [P]`
])
]
old answer
You can add the http-proxy-middleware. With it, it should be possible to rewrite the index to your apache index.
You can find an example of adding a middleware to lite-server here: https://github.com/johnpapa/lite-server#custom-configuration
Upvotes: 1