Webpack-cli: outputPath is not respected with 4.2.0

Created on 15 Dec 2020  路  10Comments  路  Source: webpack/webpack-cli

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

Bug

All 10 comments

How you run server?

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

corss-env should not matter

Can you try --public-path /?

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

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

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

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

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

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.

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 馃帀

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

Was this page helpful?
0 / 5 - 0 ratings