Skip to content

Commit

Permalink
fix: support cjs image modules
Browse files Browse the repository at this point in the history
fixes #169
  • Loading branch information
KaelWD committed Feb 5, 2021
1 parent 193ebb7 commit bccfe6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev4/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)(\?.*)?$/,
loader: 'url-loader',
options: { limit: 8000 }
options: { limit: 1024 }
}
]
},
Expand Down
8 changes: 4 additions & 4 deletions progressive-loader/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module.exports = function loader(contentBuffer) {
}

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

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

function createModule ({ data, info, type }) {
Expand All @@ -42,7 +42,7 @@ module.exports = function loader(contentBuffer) {
}
callback(
null,
`export default {src:${source},` + JSON.stringify(result).slice(1)
`module.exports = {src:${source},` + JSON.stringify(result).slice(1)
)
}

Expand Down
2 changes: 1 addition & 1 deletion progressive-loader/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function urlToRequire(url) {
const secondChar = url.charAt(1)
url = url.slice(secondChar === '/' ? 2 : 1)
}
return `require("${url}?vuetify-preload").default`
return `require("${url}?vuetify-preload")`
} else {
return `"${url}"`
}
Expand Down

0 comments on commit bccfe6d

Please sign in to comment.