Skip to content
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

Add projectDir option for WebpackConfigFactory.create #49

Closed
oreofeolurin opened this issue Apr 12, 2019 · 3 comments
Closed

Add projectDir option for WebpackConfigFactory.create #49

oreofeolurin opened this issue Apr 12, 2019 · 3 comments
Labels
enhancement New feature or request PRs open

Comments

@oreofeolurin
Copy link
Contributor

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using a different angular project structures like Nx Workspace, the src folder could end up being apps/todo/src.

ng-univeral WepbackConfigFactory configues the ContextReplacementPlugin to defaults to src which throws an error in a different angular project.

join(currentDir, 'src'), // location of your src

Expected behavior

The WebpackConfigFactory static method create should recieve a projectDir option to properly configure the ContextReplacementPlugin

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Ability to use ng-universal with other project structures like nx-workspace

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@oreofeolurin
Copy link
Contributor Author

A proposed solution looks more like this.

export class WebpackConfigFactory {
  static create(
    webpack: any,
    entry: WebpackEntries = defaultEntries,
    currentDir: string = process.cwd(),
    projectDir: string = currentDir
  ) {

projectDir can be used like this

plugins: [
        new webpack.ContextReplacementPlugin(
          // fixes WARNING Critical dependency: the request of a dependency is an expression
          /((.+)?angular(\\|\/)core(.+)?|express(.+)?|(.+)?nestjs(\\|\/)(.+)?)?/,
          join(projectDir, 'src'), // location of your src
          {}
        )
      ]

@kamilmysliwiec kamilmysliwiec added enhancement New feature or request PRs open labels Apr 15, 2019
@kamilmysliwiec
Copy link
Member

Would you like to create a PR?

@kamilmysliwiec
Copy link
Member

Published as 1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PRs open
Projects
None yet
Development

No branches or pull requests

2 participants