elementUI 打包删除无用样式,PurgecssPlugin如何配?

比如 icon库,我只用了两三个icon 。其他的希望删掉。
[purgecss]插件打包后,样式很多不对。
我如何配置或哪儿出问题了?

const glob = require('glob-all')
const PurgecssPlugin = require('purgecss-webpack-plugin')

        new PurgecssPlugin({
                paths: glob.sync([
                   path.join(__dirname, '../src/*/*.vue'),
                   path.join(__dirname, '../src/App.vue'),
                   path.join(__dirname, '../ssr/app.js'),
                   path.join(__dirname, '../ssr/entry-client.js')
                ], { nodir: true }),
              defaultExtractor (content) {
                const contentWithoutStyleBlocks = content.replace(/<style[^]+?<\/style>/gi, '')
                return contentWithoutStyleBlocks.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || []
              },
              rejected: true,
              whitelist: [],
              whitelistPatterns: [ /-(leave|enter|appear)(|-(to|from|active))$/, /^(?!(|.*?:)cursor-move).+-move$/, /^router-link(|-exact)-active$/, /data-v-.*/ ],
        })
阅读 2.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题