webpack中link的css地址修改?真心求答

目前现象:使用html-webpack-plugin和extract-text-webpack-plugin生成html中自动插入的link地址和extract-text-webpack-plugin设置的filename一致
clipboard.png

<link href="index/css/style.css" rel="stylesheet"></head>
new exTxt({
            filename:'[name]/css/style.css'
        }),
new htmlWebpackPlugin({
                        filename:path.resolve(pathConfig.dist,`./${app}/index.html`),
                        template:path.resolve(pathConfig.apps,`./${app}/page.js`),
                        inject:"body",
                        minify: {
                            // removeComments: true,
                            // collapseWhitespace: true,
                            // removeAttributeQuotes: true
                            // more options:
                            // https://github.com/kangax/html-minifier#options-quick-reference
                        },
                        chunks:[app,'commons/commons']
                    });

目的:正确地址应该是css/style.css,有哪位大神告诉我怎么修改啊
官网上有这一步

plugins: [
  new ExtractTextPlugin({
    filename:  (getPath) => {
      return getPath('css/[name].css').replace('css/js', 'css');
    },
    allChunks: true
  })
]

但是我试了报错,提示filename必须是string

阅读 3.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题