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

关于构建时去除多余css的问题 #40

Open
xl-wolf opened this issue Jul 17, 2020 · 1 comment
Open

关于构建时去除多余css的问题 #40

xl-wolf opened this issue Jul 17, 2020 · 1 comment

Comments

@xl-wolf
Copy link

xl-wolf commented Jul 17, 2020

作者好!按照所给的配置报错class Extractor必须要用new关键字调用
然而new 这个Extractor类之后依旧构建失败,报错t不是函数 这个本人就一头雾水了!希望作者帮忙赐教解决一下

@mollykannn
Copy link

mollykannn commented Aug 29, 2020

找了一點線索 https://gist.github.com/josephan/45569c48ee4867237e89417aed283103
大概是因為purgecss-webpack-plugin從v1升上了v2的問題....

把這段

          extractors: [
            {
              extractor: class Extractor {
                static extract(content) {
                  const validSection = content.replace(
                    /<style([\s\S]*?)<\/style>+/gim,
                    ""
                  );
                  return (
                    validSection.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || []
                  );
                }
              },
              extensions: ["html", "vue"]
            }
          ],

改為

            extractors: [
              {
                extractor: (content) => {
                  const validSection = content.replace(/<style([\s\S]*?)<\/style>+/gim, "");
                  return validSection.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || [];
                },
                extensions: ["html", "vue"],
              },
            ],

就可以了

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

2 participants