mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2025-05-03 18:12:55 +08:00
move extendPackage
This commit is contained in:
parent
24f3dc0cac
commit
ac88d22997
62
generator.js
62
generator.js
@ -5,52 +5,30 @@ const isBinary = require('isbinaryfile')
|
|||||||
const stripJsonComments = require('strip-json-comments')
|
const stripJsonComments = require('strip-json-comments')
|
||||||
|
|
||||||
|
|
||||||
async function generate(dir, files, base = '') {
|
|
||||||
|
|
||||||
const glob = require('glob')
|
|
||||||
|
|
||||||
glob.sync('**/*', {
|
|
||||||
cwd: dir,
|
|
||||||
nodir: true
|
|
||||||
}).forEach(rawPath => {
|
|
||||||
const sourcePath = path.resolve(dir, rawPath)
|
|
||||||
if (isBinary.sync(sourcePath)) {
|
|
||||||
files[path.join(base, rawPath)] = fs.readFileSync(sourcePath) // return buffer
|
|
||||||
} else {
|
|
||||||
const content = fs.readFileSync(sourcePath, 'utf-8')
|
|
||||||
if (sourcePath.indexOf('manifest.json') !== -1 || sourcePath.indexOf('pages.json') !== -1) {
|
|
||||||
files[path.join(base, rawPath)] = JSON.stringify(JSON.parse(stripJsonComments(content)), null, 2)
|
|
||||||
} else {
|
|
||||||
files[path.join(base, rawPath)] = content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = (api, options, rootOptions) => {
|
module.exports = (api, options, rootOptions) => {
|
||||||
|
|
||||||
api.render(async function(files) {
|
api.extendPackage(pkg => {
|
||||||
|
delete pkg.postcss
|
||||||
|
delete pkg.browserslist
|
||||||
|
return {
|
||||||
|
dependencies: {
|
||||||
|
'flyio': '^0.6.2',
|
||||||
|
'vuex': '^3.0.1',
|
||||||
|
'@dcloudio/uni-h5': '*'
|
||||||
|
},
|
||||||
|
devDependencies: {
|
||||||
|
'@dcloudio/vue-cli-plugin-uni': '*'
|
||||||
|
},
|
||||||
|
browserslist: [
|
||||||
|
'last 3 versions',
|
||||||
|
'Android >= 4.4',
|
||||||
|
'ios >= 8'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
api.extendPackage(pkg => {
|
api.render(async function(files) {
|
||||||
delete pkg.postcss
|
|
||||||
delete pkg.browserslist
|
|
||||||
return {
|
|
||||||
dependencies: {
|
|
||||||
'flyio': '^0.6.2',
|
|
||||||
'vuex': '^3.0.1',
|
|
||||||
'@dcloudio/uni-h5': '*'
|
|
||||||
},
|
|
||||||
devDependencies: {
|
|
||||||
'@dcloudio/vue-cli-plugin-uni': '*'
|
|
||||||
},
|
|
||||||
browserslist: [
|
|
||||||
'last 3 versions',
|
|
||||||
'Android >= 4.4',
|
|
||||||
'ios >= 8'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Object.keys(files).forEach(name => {
|
Object.keys(files).forEach(name => {
|
||||||
delete files[name]
|
delete files[name]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user