Akryum / Akryum/vue-cli-plugin-ssr

Duplicated CSS rules in production

未关闭
#46 15 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
441
派生
69
PR 合并指标
30 天内没有已合并 PR

描述

When using this CLI plugin, there are duplicated CSS rules when using CSS modules and the "composes" feature. This seems to be caused by the critical CSS that's inlined into the `` and is both happening in development and production (main issue).

I've created the following test repo (https://github.com/mrksbnch/vue-ssr-css-issue) that I created using `vue create` (Vue router as the only feature) and `vue add @akryum/vue-cli-plugin-ssr`. Afterwards, I added a test.css file in the folder `assets` and composed (``) two style declarations from that file in `Home.vue` and `HelloWorld.vue`.

You can see the duplicated rules after running `npm run ssr:serve` or `npm run ssr:build` and `npm run ssr:start` in the dev tools:

<img width="1279" alt="screen shot 2019-01-06 at 18 32 42" src="https://user-images.githubusercontent.com/15638734/50739619-6fa76300-11e3-11e9-863c-268dabad673a.png">

Both CSS rules are inlined on the server side (`<style data-vue-ssr-id>`):

<img width="554" alt="screen shot 2019-01-06 at 18 33 20" src="https://user-images.githubusercontent.com/15638734/50739658-b6955880-11e3-11e9-970f-d8cad662c4ff.png">

This is just a simple test repo with only one CSS rule. In a proper app this will cause a lot (!) of duplicated CSS rules and increase the file size by quite a bit. I've tested it with a simple app and I noticed some rules being duplicated 5 or 6 times.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。