ElemeFE / page-skeleton-webpack-plugin

Webpack plugin to generate the skeleton page automatically
MIT License
2.8k stars 394 forks source link

npm run build 没有替换根目录下的 html文件 #113

Open minggangLu opened 5 years ago

minggangLu commented 5 years ago

Description

用的sale demo,骨架屏静态页面能生成,运行npm run build 的时候没有将根目录下的 替换为骨架屏样式,是要把根目录下的标签替换调么,如果不替换,怎么将 骨架屏静态页面和真实的页面交替显示(数据没加载出来显示 dist 下的html,加载出来后显示根目录下的页面),还是说这个只是个生成静态骨架屏的工具?

PS:如果整个项目没用vue-router,还能使用该插件生成骨架屏么

cuilingh00 commented 5 years ago

Description

用的sale demo,骨架屏静态页面能生成,运行npm run build 的时候没有将根目录下的 替换为骨架屏样式,是要把根目录下的标签替换调么,如果不替换,怎么将 骨架屏静态页面和真实的页面交替显示(数据没加载出来显示 dist 下的html,加载出来后显示根目录下的页面),还是说这个只是个生成静态骨架屏的工具?

PS:如果整个项目没用vue-router,还能使用该插件生成骨架屏么 同问,快疯了,没人解答

Jocs commented 5 years ago

可以的。

1927344728 commented 4 years ago

项目中没有用vue-router,骨架预览页面空白。浏览器控制台报错:

TypeError: Cannot read property 'html' of undefined
    at a.setCode (bundle.4da48e9f37a58e077c95.js:formatted:15435)
    at fn.e.$emit (bundle.4da48e9f37a58e077c95.js:formatted:2006)
    at _.de.onmessage (bundle.4da48e9f37a58e077c95.js:formatted:16178)
    at _.r.dispatchEvent (bundle.4da48e9f37a58e077c95.js:formatted:13468)
    at bundle.4da48e9f37a58e077c95.js:formatted:16917
    at Array.forEach (<anonymous>)
    at _._transportMessage (bundle.4da48e9f37a58e077c95.js:formatted:16915)
    at c.o.emit (bundle.4da48e9f37a58e077c95.js:formatted:134)
    at WebSocket.ws.onmessage (bundle.4da48e9f37a58e077c95.js:formatted:17590)

TypeError: Cannot read property 'url' of undefined
    at a.<anonymous> (bundle.4da48e9f37a58e077c95.js:formatted:16105)
    at a.e._render (bundle.4da48e9f37a58e077c95.js:formatted:2066)
    at a.n (bundle.4da48e9f37a58e077c95.js:formatted:3436)
    at At.get (bundle.4da48e9f37a58e077c95.js:formatted:1114)
    at At.run (bundle.4da48e9f37a58e077c95.js:formatted:1168)
    at Mt (bundle.4da48e9f37a58e077c95.js:formatted:1053)
    at Array.<anonymous> (bundle.4da48e9f37a58e077c95.js:formatted:834)
    at Ke (bundle.4da48e9f37a58e077c95.js:formatted:800)

配置如下:

new SkeletonPlugin({
  pathname: path.resolve(__dirname, `../html_shell`), // 用来存储 shell 文件的地址
  staticDir: path.resolve(__dirname, '../dist'), // 最好和 `output.path` 相同
  routes: ['/path1/path2/page1.html'], // 将需要生成骨架屏的路由添加到数组中
})

多页面的项目中,routes参数应该怎么来配置?

katoto commented 4 years ago

还好,看了这个,遇到的坑,都解决了,https://juejin.im/post/5ed4c22ae51d4578810b5459