diff --git a/.gitignore b/.gitignore index 0fb9d29..625e125 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ dist/ +dist-dev/ types node_modules .DS_Store diff --git a/package.json b/package.json index eb71556..44f7aa4 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "scripts": { "build": "rollup -c", - "dev": "rollup -c -w" + "dev": "NODE_ENV=development rollup -c -w" }, "bugs": { "url": "https://github.com/NervJS/taro-plugin-platform-xhs/issues" diff --git a/rollup.config.js b/rollup.config.js index fd86440..59db9ff 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,6 +4,8 @@ import json from '@rollup/plugin-json' const cwd = __dirname +const output = process.env.NODE_ENV === 'development' ? 'dist-dev' : 'dist'; + const base = { external: ['@tarojs/shared', '@tarojs/service'], plugins: [typescript({ @@ -16,7 +18,7 @@ const base = { const compileConfig = { input: join(cwd, 'src/index.ts'), output: { - file: join(cwd, 'dist/index.js'), + file: join(cwd, `${output}/index.js`), format: 'cjs', sourcemap: true, exports: 'named' @@ -28,7 +30,7 @@ const compileConfig = { const runtimeConfig = { input: join(cwd, 'src/runtime.ts'), output: { - file: join(cwd, 'dist/runtime.js'), + file: join(cwd, `${output}/runtime.js`), format: 'es', sourcemap: true }, @@ -39,7 +41,7 @@ const runtimeConfig = { const runtimeUtilsConfig = { input: join(cwd, 'src/runtime-utils.ts'), output: { - file: join(cwd, 'dist/runtime-utils.js'), + file: join(cwd, `${output}/runtime-utils.js`), format: 'es', sourcemap: true }, diff --git a/src/components.ts b/src/components.ts index fbf2040..0480eb7 100644 --- a/src/components.ts +++ b/src/components.ts @@ -6,7 +6,8 @@ export const components = { size: '23' }, Button: { - 'data-channel': '', + 'data-channel': singleQuote(''), + 'share-type': singleQuote('normal'), bindGetPhoneNumber: '', bindGetUserInfo: '', bindOpenSetting: '', diff --git a/src/template.ts b/src/template.ts index 3f52d5e..55aea7b 100644 --- a/src/template.ts +++ b/src/template.ts @@ -15,6 +15,13 @@ export class Template extends RecursiveTemplate { replacePropName (name: string, value: string, componentName:string) { if (value === 'eh') return name.toLowerCase() + + /** + * button 组件, 修改 share-type 字段为 data-share-type + */ + if (componentName === 'button') { + if (name === 'share-type') return 'data-share-type' + } return name } }