forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
179 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const path = require('path') | ||
const del = require('del') | ||
|
||
const { | ||
error | ||
} = require('@vue/cli-shared-utils') | ||
|
||
const Service = require('@vue/cli-service') | ||
|
||
const vueConfig = require('./vue.config.js') | ||
|
||
const extendsApiPath = path.resolve(__dirname, '../lib/h5/extends-api') | ||
|
||
vueConfig.configureWebpack.resolve.alias['uni-invoke-api'] = extendsApiPath | ||
|
||
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd(), { | ||
inlineOptions: vueConfig | ||
}) | ||
// 删除 cache 目录 | ||
del.sync(['node_modules/.cache']) | ||
|
||
let pluginDir = process.argv[2] | ||
if (!pluginDir) { | ||
console.error(`缺少参数`) | ||
process.exit(0) | ||
} | ||
|
||
if(pluginDir.indexOf('/') === -1){ | ||
pluginDir = path.resolve(__dirname,'../packages/uni-'+pluginDir) | ||
} | ||
|
||
const pkg = require(path.join(pluginDir, 'package.json')) | ||
if (!pkg['uni-app']) { | ||
console.error(`缺少 uni-app 配置`) | ||
process.exit(0) | ||
} | ||
|
||
service.webpackRawConfigFns.push(function () { | ||
return { | ||
resolve: { | ||
alias: { | ||
'uni-platform/service/api.js': extendsApiPath, | ||
'uni-sub-platform': path.resolve(pluginDir, 'src'), | ||
'uni-platform-api': path.resolve(__dirname, '../src/platforms/h5/service/api'), | ||
'uni-sub-platform-api': path.resolve(pluginDir, 'src/service/api') | ||
} | ||
}, | ||
module: { | ||
rules: [{ | ||
test: path.resolve(__dirname, '../src/platforms/h5/service/api/index.js'), | ||
use: [{ | ||
loader: path.resolve(__dirname, '../lib/extends-loader'), | ||
options: { | ||
'extends': path.resolve(pluginDir, 'src/service/api'), | ||
'base': path.resolve(__dirname, '../src/platforms/h5/service/api') | ||
} | ||
}] | ||
}] | ||
} | ||
} | ||
}) | ||
|
||
service.run('build', { | ||
name: 'index', | ||
watch: process.env.UNI_WATCH === 'true', | ||
target: 'lib', | ||
formats: process.env.UNI_WATCH === 'true' ? 'umd' : 'umd-min', | ||
entry: './lib/h5/main.js', | ||
dest: path.join(pluginDir, 'dist'), | ||
clean: true, | ||
mode: process.env.NODE_ENV | ||
}).then(function () {}).catch(err => { | ||
error(err) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const glob = require('glob') | ||
const loaderUtils = require('loader-utils') | ||
|
||
const isWin = /^win/.test(process.platform) | ||
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) | ||
|
||
module.exports = function loader(source) { | ||
const options = loaderUtils.getOptions(this) | ||
const baseDir = options['base'] | ||
const extendsDir = options['extends'] | ||
|
||
const exportCode = [] | ||
const extendsFiles = [] | ||
// extends目录均导出 | ||
glob.sync('**/*.js', { | ||
cwd: extendsDir | ||
}).forEach(file => { | ||
if (file === 'index.js') { | ||
return | ||
} | ||
extendsFiles.push(file) | ||
exportCode.push(`export * from 'uni-sub-platform-api/${normalizePath(file)}'`) | ||
}) | ||
//base目录中有,extends无的导出 | ||
glob.sync('**/*.js', { | ||
cwd: baseDir | ||
}).forEach(file => { | ||
if (file === 'index.js') { | ||
return | ||
} | ||
if (!extendsFiles.includes(file)) { | ||
exportCode.push(`export * from 'uni-platform-api/${normalizePath(file)}'`) | ||
} | ||
}) | ||
console.log(exportCode.join('\n')) | ||
return exportCode.join('\n') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'uni-sub-platform/service/index' | ||
import * as api from 'uni-platform/service/api/index' | ||
export default api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
{ | ||
"name": "@dcloudio/uni-h5", | ||
"version": "2.0.0-alpha-26420200309002", | ||
"description": "uni-app h5", | ||
"main": "dist/index.umd.min.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/dcloudio/uni-app.git", | ||
"directory": "packages/uni-h5" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "fxy060608", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"base64-arraybuffer": "^0.2.0", | ||
"intersection-observer": "^0.7.0", | ||
"safe-area-insets": "^1.4.1" | ||
}, | ||
"uni-app": { | ||
"name": "h5", | ||
"title": "H5", | ||
"main": "lib/h5/uni.config.js" | ||
}, | ||
"gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" | ||
{ | ||
"name": "@dcloudio/uni-h5", | ||
"version": "2.0.0-alpha-26420200309002", | ||
"description": "uni-app h5", | ||
"main": "dist/index.umd.min.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/dcloudio/uni-app.git", | ||
"directory": "packages/uni-h5" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "fxy060608", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"base64-arraybuffer": "^0.2.0", | ||
"intersection-observer": "^0.7.0", | ||
"safe-area-insets": "^1.4.1" | ||
}, | ||
"uni-app": { | ||
"name": "h5", | ||
"title": "H5", | ||
"main": "lib/h5/uni.config.js" | ||
}, | ||
"gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import baseApi from 'uni-core/service/api' | ||
import platformApi from 'uni-platform/service/api' | ||
import platformApi from 'uni-invoke-api' | ||
|
||
export default Object.assign(Object.create(null), baseApi, platformApi) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters