Skip to content

Commit

Permalink
fix: style loader export error
Browse files Browse the repository at this point in the history
  • Loading branch information
loongfay authored and meixg committed Aug 10, 2022
1 parent 8c44b0b commit 4abf9db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/style-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ function extractCssResult(content: string, loaderContext: loader.LoaderContext,

// 这里严重依赖 file-loader 的输出格式:
// export default __webpack_public_path__ + 'file-name.svg';
eval(source.replace(/^export default/, 'path ='));
// module.exports = __webpack_public_path__ + 'path/to/sth.eot';

const reg = /^(export default|module.exports =)/;

// 匹配成功再赋值,防止把模块导出为字符串 `module.exports = __webpack_public_path__ + 'path/to/sth.eot';`
if (reg.test(source)) {
eval(source.replace(reg, 'path ='));
}

fileMap[req] = path;
resolve();
Expand Down

0 comments on commit 4abf9db

Please sign in to comment.