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

outputPath is not respected with 4.2.0 #2242

Closed
beckerei opened this issue Dec 15, 2020 · 10 comments · Fixed by #2271
Closed

outputPath is not respected with 4.2.0 #2242

beckerei opened this issue Dec 15, 2020 · 10 comments · Fixed by #2271
Labels

Comments

@beckerei
Copy link

beckerei commented Dec 15, 2020

Describe the bug

We can server our repostiory against our production build with this config. I did cut some (hopefully useless) information, to make it easier to get.

const devSerer = {
      historyApiFallback: true,
      publicPath: '/',
      disableHostCheck: true,
      host: 'localhost.some-domain.com',
      port: 443,
      inline: true,
      hot: true,
      noInfo: false,
      stats: 'minimal',
      proxy: [
        {
          context: ['/api/',],
          target: 'https://www.some-domain.com'',
          changeOrigin: true,
        },
      ],
    }

const output = {
        filename: '[name].[hash].js',
        chunkFilename: '[name].[hash].chunk.js',
        path: path.join(__dirname, 'dist'),
        publicPath: '/app/',
      },

Using HtmlWebpackPlugin with some pretty boring index.ejs file

What is the current behavior?

Before 4.2.0 everything work as expected:

Scripts were loaded from the /app, index was served from /

Now the html contains

<script src="/app/runtime.4f07461f24ae6827cfbb.js"></script>

This returns 404, while accessing just /runtime.4f07461f24ae6827cfbb.js works.
So I assume either index is served from the wrong folder, or assets are not put in the correct folder.

Using publicPath: '/' does work, but would also effect production builds, which is not desired.

To Reproduce

~~

Expected behavior

It should work as before.

Screenshots

Please paste the results of webpack-cli info here, and mention other relevant information

Additional context

Webpack Version is 4.44.2

@beckerei beckerei added the Bug label Dec 15, 2020
@alexander-akait
Copy link
Member

How you run server?

@beckerei
Copy link
Author

cross-env NODE_ENV=development webpack serve --env=development --progress

corss-env should not matter

@alexander-akait
Copy link
Member

Can you try --public-path /?

@beckerei
Copy link
Author

I get [webpack-cli] Unknown argument: --public-path regardless of how I pass the /

@alexander-akait
Copy link
Member

Yep, bug, need to fix, as workaround you can set output.publicPath: '/' for serve command:

cross-env NODE_ENV=development WEBPACK_MODE=serve webpack serve --env=development --progress

and use process.env.WEBPACK_MODE in webpack.config.js

@snitin315
Copy link
Member

I get [webpack-cli] Unknown argument: --public-path regardless of how I pass the /

Maybe it's --output-public-path /

@alexander-akait
Copy link
Member

Anyway I think it is fixed in master, I will add tests in near future

@beckerei
Copy link
Author

output-public-path doesn't work either.

Anyway I think it is fixed in master, I will add tests in near future

But wow, I was not expecting this 🚀
Let me know if I can help you out, testing a beta release or so.

@beckerei
Copy link
Author

I checked out the latest release (4.3.0). Our setup works again without any changes.

Thank you.

Despite these tiring times I wish you all the best for next year 🎉

@alexander-akait
Copy link
Member

Let's keep open, I want to add tests for this case to avoid regressions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants