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

脚手架开发中遇到的坑 #45

Open
keep-run opened this issue Sep 9, 2021 · 0 comments
Open

脚手架开发中遇到的坑 #45

keep-run opened this issue Sep 9, 2021 · 0 comments

Comments

@keep-run
Copy link
Owner

keep-run commented Sep 9, 2021

1、webpack5devServer其中后,打开的页面,控制台显示 socket链接失败, 大概率是端口问题,换一个端口就好了;
2、 利用mini-css-extract-plugin插件提取css后,修改js文件,页面更新,但是修改css文件,页面不更新。检查该插件的配置:

  new MiniCssExtractPlugin({
    filename: 'bundle.[contenthash].css'     //输出css文件名称
  })

开发环境下,不要带hash或者contenthash,就可以解决刷新问题。生产环境需要带,可以用来解决缓存问题。 webpack官网有这样一个一笔带过的解释:

使用 filename: "[contenthash].css" 启动长期缓存。根据需要添加 [name]。

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

No branches or pull requests

1 participant