ServiceWorker脱机-HTML中没有className

黑斯彭

我一直在尝试使用Workbox在我的React 16项目中实现缓存。由于页面仍以offline模式呈现,因此似乎正在缓存某些内容但是我似乎无法弄清楚,为什么我的缓存版本在元素上不包含任何className。

普通版: 互联网连接示例

缓存版本 网站的缓存版本

另外,预取似乎也可以正常工作: 预取标签

我已经通过Webpack通过以下代码块实现了Workbox:

new workboxPlugin({
  globDirectory: 'build/client',
  globPatterns: ['**/*.{html,js,css,png,jpeg}'],
  swDest: './build/client/sw.js',
}),

这可能是什么原因?即使也应该缓存图像,也不会加载图像。

编辑:

It seems like the .js files are not being loaded. The main & vendor .js files contain the content required to assign classNames.

.js文件找不到

As you can see, the .js files can't be found. This is in a preload, but removing them just transfers the error to the <script /> including the files. Also the location of the service worker registration doesn't seem to matter.

Side note: My classnames are generated by using import styles from './index.scss' => <div className={styles.container} />

Hespen

It seems like my SSR (server.webpack.config) failed on the CSS loading. I had to modify my server config to match the client config regarding the css loader.

Because I didn't have this at first, it would read the scss files as a normal txt files, which he couldn't recognize, and therefor couldn't use the styles.container method.

放置适当的scss文件加载程序可以解决此问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ServiceWorker-脱机时缓存所有失败的发帖请求,在线时重新提交

仅在脱机时使用ServiceWorker缓存

Crashlytics中的脱机崩溃报告

如何在Android中显示没有数据库的脱机在线数据

数据库 (Teradata) 中没有更多的假脱机空间

没有数据时删除空假脱机文件

ServiceWorker范围中的页面URL

ServiceWorker /缓存API中的通配符

在chef-solo脱机安装之前,如何从食谱中收集所有脱机资源

ServiceWorker:对于JavaScript触发的请求,没有FetchEvent吗?

DOMException:无法注册ServiceWorker:脚本没有MIME类型

脱机程序获取HTML IMAGE MAP

是否有Here平台的本地(脱机)版本?

带有参数的sqlplus假脱机文件

具有持久数据的脱机网页缓存

在假脱机文件中隐藏SQL>语句

Serviceworker 订阅在 Firefox 中工作,但在 Chrome 中无效。抛出错误:“注册失败 - 没有 Service Worker””

在ServiceWorker中访问indexedDB。比赛条件

在本地(脱机)运行Web应用程序且没有IIS

单击“管理脱机文件”在同步中心中没有任何作用

脱机模式下没有com.github.bumptech.glide:compiler:4.9.0的缓存版本

没有io.fabric.tools:gradle:1.+的缓存版本列表可用于脱机模式

在没有Internet的情况下以脱机模式运行。显示位置..仅不显示图形

没有互联网连接时,仅以角度pwa显示自定义的脱机页面

添加 className 但 css 在 ReactJS 组件中没有影响

生成可脱机工作的Bokeh html文件

如何将.htaccess与脱机html一起使用?

通过带有脱机标记的Maven安装Tycho

具有重写URL的脱机Web应用程序