Skip to content

index.html in another folder #2951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Oct 29, 2016 · 6 comments
Closed

index.html in another folder #2951

ghost opened this issue Oct 29, 2016 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2016

OS?

Windows 8

Versions.

angular-cli: 1.0.0-beta.19-3
node: 6.8.0
os: win32 x64

Repro steps.

i have standard config with changes only in src/dist folders and updated tsconfig.json references for it(not interested, it works fine).

{
  "apps": [
    {
      "root": "frontend/sources/main",
      "outDir": "frontend/processed/main.bundled",
    }
  ]
}

but i place index.html in ${www}/ folder instead of ${www}/frontend/processed/main.bundled/

The log given by the failure.

browser cannot download scripts/fonts/icon because they are in /frontend/processed/main.bundled/ subfolder.

<base href="/">
<link rel="icon" type="image/x-icon" href="public/assets/favicon.ico">
<script type="text/javascript" src="inline.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="scripts.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js"></script>

is it posible to talk angular-cli to use frontend/processed/main.bundled/ prefix for processed references?
i do not dound it in schema.d.ts

Mention any other details that might be useful.

i do not want to place files in ${www}/ folder.
i know about proxy ability. it is not suitable

@Meligy
Copy link
Contributor

Meligy commented Oct 31, 2016

Did you change the index property in angular-cli.json?

@Meligy
Copy link
Contributor

Meligy commented Oct 31, 2016

One thing you can do is use the --bh (base-href) argument with ng build and ng serve.

Like ng build --bh "./frontend/processed/main.bundled/".

@filipesilva
Copy link
Contributor

We don't support the scenario you're trying to do. The build system expects index.html to be inside the folder defined in root.

@jamiepgs
Copy link

I was trying to achieve something similar, where it was being integrated into a legacy Symfony1 app where resources are stored in /resources/foo-app and the built js is in /js/foo-app/* and the index.html is a template that's routed by Symfony at domain.com/foo-app/. I managed to get it working using Gulp to make necessary adjustments. Here is an example of the task:

gulp.task('foo-app-build', function(e){
            gulp.src(['web/js/foo-app/index.html'])
                .pipe(dom(function(){
                    var scripts = this.querySelectorAll('script[src]'),
                        i       = scripts.length;

                    while(i--) {
                        var src = scripts[i].getAttribute('src');
                        scripts[i].setAttribute('src', '/js/foo-app/' + src);
                    }

                    return this;
                }))
                .pipe(insert.prepend('<?php decorate_with(false); ?>'))
                .pipe(rename('indexSuccess.php'))
                .pipe(gulp.dest('apps/admin/modules/foo-app/templates/'));

// For css resources such as icon fonts and svg's etc           
gulp.src(['web/js/foo-app/styles.*.js'])
                .pipe(replace(/\M\.exports=N\.p\+"/g, 'M.exports=N.p+"/js/foo-app/'))
                .pipe(gulp.dest('web/js/foo-app/'))
                .pipe(gzip())
                .pipe(gulp.dest('web/js/foo-app/'))
        });
});

Bit hacky but works

@ghost
Copy link
Author

ghost commented Jan 29, 2017

@Meligy, --bh affects <base href=""/>

i need affect only <script src="" /> and <link href="" rel="stylesheet">

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants