Commit 75de0fa5 authored by Colder Xihk's avatar Colder Xihk Committed by Tim Neutkens

update with-antd-mobile example (#2425)

support windows path

remove unused hammerjs hack

remove unused 'style/css' resolver
parent 071f526b
...@@ -3,34 +3,20 @@ const fs = require('fs') ...@@ -3,34 +3,20 @@ const fs = require('fs')
const requireHacker = require('require-hacker') const requireHacker = require('require-hacker')
function setupRequireHacker () { function setupRequireHacker () {
requireHacker.resolver((filename, module) => { const webjs = '.web.js'
if (filename.endsWith('/style/css')) { const webModules = ['antd-mobile', 'rmc-picker'].map(m => path.join('node_modules', m))
return requireHacker.resolve(`${filename}.web.js`, module)
}
})
requireHacker.hook('js', filename => { requireHacker.hook('js', filename => {
if (filename.endsWith('/node_modules/hammerjs/hammer.js')) { if (filename.endsWith(webjs) || webModules.every(p => !filename.includes(p))) return
return `
module.exports = {}
`
}
if (
filename.endsWith('.web.js') ||
!filename.includes('/node_modules/') ||
['antd-mobile', 'rmc-picker'].every(p => !filename.includes(p))
) return
const webjs = filename.replace(/\.js$/, '.web.js') const webFilename = filename.replace(/\.js$/, webjs)
if (!fs.existsSync(webjs)) return if (!fs.existsSync(webFilename)) return
return fs.readFileSync(webjs, { encoding: 'utf8' }) return fs.readFileSync(webFilename, { encoding: 'utf8' })
}) })
requireHacker.hook('svg', filename => { requireHacker.hook('svg', filename => {
const id = path.basename(filename).replace(/\.svg$/, '') return requireHacker.to_javascript_module_source(`#${path.parse(filename).name}`)
return requireHacker.to_javascript_module_source(`#${id}`)
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment