美文网首页
Vue-Error: Path variable [conten

Vue-Error: Path variable [conten

作者: 李大鱼_ | 来源:发表于2019-10-16 09:28 被阅读0次

    webPack 升级到 4.3.0 导致 extract-text-webpack-plugin 无法使用,extract-text-webpack-plugin原始使用的方法如下:

    config.plugins.push(
          new ExtractPlugin('styles.[contenthash:8].css')
    )
    

    报错信息如下:

    92% additional asset processing ExtractTextPluginF:\vue3\node_modules\webpack\lib\TemplatedPathPlugin.js:44
                                    throw new Error(
                                    ^
    
    Error: Path variable [contenthash:8] not implemented in this context: styles.[contenthash:8].css
        at fn (F:\vue3\node_modules\webpack\lib\TemplatedPathPlugin.js:44:11)
        at fn (F:\vue3\node_modules\webpack\lib\TemplatedPathPlugin.js:32:16)
        at String.replace (<anonymous>)
    

    是因为webpack4.3 包含了contenthash 这个关键字段,所以在ExtractPlugin 中不能使用contenthash,
    使用mds:contenthash:hex:8 替代

    config.plugins.push(
        new ExtractPlugin('styles.[contenthash:8].css')
    )
    

    相关文章

      网友评论

          本文标题:Vue-Error: Path variable [conten

          本文链接:https://www.haomeiwen.com/subject/epxryctx.html