2 years ago

#38816

test-img

Joan Na

I changed publicPath to /statistic/ and webpack doesn't load script to /statistic/any_link

React 17 + @reach/router + webpack 4

I have webpack config:

module.exports = {
  context: path.resolve(__dirname, 'src'),
  entry: [
    'react-hot-loader/patch',
    path.resolve(__dirname, './src/styles/styles.pcss'),
    path.resolve(__dirname, './src/pages'),
  ],
  output: {
    publicPath: '/statistic/',
    filename: 'bundle.js',
    path: path.resolve(__dirname, './statistic'),`enter code here`
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: '[name].css',
    }),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, 'public', 'index.html'),
      favicon: 'favicon.png',
    }),
  ],
  devServer: {
    port: 3000,
    hot: true,
    historyApiFallback: true,
  },
};

Also router settings:

export const AppRouter = () => (
    <Router basepath="/statistic" primary={false}>
      <CampaignsPage path={CAMPAIGNS_PAGE_URL} />
    </Router>
);

But I have script on mypage.com/statistic/

Index.html

but I don't see it on mypage.com/statistic/campaigns after reload

campaigns.html

How to fix that?

reactjs

webpack

reach-router

0 Answers

Your Answer

Accepted video resources