Skip to content

Commit bccfe6d

Browse files
committed
fix: support cjs image modules
fixes #169
1 parent 193ebb7 commit bccfe6d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

dev4/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
{
5454
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)(\?.*)?$/,
5555
loader: 'url-loader',
56-
options: { limit: 8000 }
56+
options: { limit: 1024 }
5757
}
5858
]
5959
},

progressive-loader/loader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ module.exports = function loader(contentBuffer) {
1818
}
1919

2020
/** @see https://github.com/zouhir/lqip-loader */
21-
const contentIsUrlExport = /^export default "data:(.*)base64,(.*)/.test(
21+
const contentIsUrlExport = /^(export default|module.exports =) "data:(.*)base64,(.*)/.test(
2222
content
2323
)
24-
const contentIsFileExport = /^export default (.*)/.test(content)
24+
const contentIsFileExport = /^(export default|module.exports =) (.*)/.test(content)
2525
let source = ''
2626

2727
if (contentIsUrlExport) {
@@ -32,7 +32,7 @@ module.exports = function loader(contentBuffer) {
3232
const fileLoader = require('file-loader')
3333
content = fileLoader.call(this, contentBuffer)
3434
}
35-
source = content.match(/^export default (.*);/)[1]
35+
source = content.match(/^(?:export default|module.exports =) (.*);/)[1]
3636
}
3737

3838
function createModule ({ data, info, type }) {
@@ -42,7 +42,7 @@ module.exports = function loader(contentBuffer) {
4242
}
4343
callback(
4444
null,
45-
`export default {src:${source},` + JSON.stringify(result).slice(1)
45+
`module.exports = {src:${source},` + JSON.stringify(result).slice(1)
4646
)
4747
}
4848

progressive-loader/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function urlToRequire(url) {
2929
const secondChar = url.charAt(1)
3030
url = url.slice(secondChar === '/' ? 2 : 1)
3131
}
32-
return `require("${url}?vuetify-preload").default`
32+
return `require("${url}?vuetify-preload")`
3333
} else {
3434
return `"${url}"`
3535
}

0 commit comments

Comments
 (0)