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
1 parent
614a3df
commit 4826959
Showing
4 changed files
with
1,609 additions
and
635 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,42 @@ | ||
import { endent } from '@dword-design/functions' | ||
|
||
export default endent` | ||
// Import vue components | ||
import * as components from '.'; | ||
// install function executed by Vue.use() | ||
const install = function installVueIcon(Vue) { | ||
if (install.installed) return; | ||
install.installed = true; | ||
Object.entries(components).forEach(([componentName, component]) => { | ||
Vue.component(componentName, component); | ||
}); | ||
}; | ||
// Create module definition for Vue.use() | ||
const plugin = { | ||
install, | ||
}; | ||
// To auto-install on non-es builds, when vue is found | ||
// eslint-disable-next-line no-redeclare | ||
/* global window, global */ | ||
if ('false' === process.env.ES_BUILD) { | ||
let GlobalVue = null; | ||
if (typeof window !== 'undefined') { | ||
GlobalVue = window.Vue; | ||
} else if (typeof global !== 'undefined') { | ||
GlobalVue = global.Vue; | ||
} | ||
if (GlobalVue) { | ||
GlobalVue.use(plugin); | ||
} | ||
} | ||
// Default export is library as a whole, registered via Vue.use() | ||
export default plugin; | ||
// To allow individual component use, export components | ||
// each can be registered via Vue.component() | ||
export * from '.'; | ||
` |
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,8 +1,32 @@ | ||
import componentConfig from '@dword-design/base-config-component' | ||
import execa from 'execa' | ||
import { outputFile, remove } from 'fs-extra' | ||
import getPackageName from 'get-package-name' | ||
import P from 'path' | ||
|
||
import entry from './entry' | ||
|
||
export default { | ||
...componentConfig, | ||
packageConfig: { | ||
main: 'dist/index.js', | ||
commands: { | ||
...componentConfig.commands, | ||
prepublishOnly: async () => { | ||
try { | ||
await outputFile(P.join('src', 'entry.js'), entry) | ||
await remove('dist') | ||
await execa( | ||
getPackageName(require.resolve('rollup')), | ||
[ | ||
'--config', | ||
require.resolve('@dword-design/rollup-config-component'), | ||
], | ||
{ | ||
env: { NODE_ENV: 'production', stdio: 'inherit' }, | ||
} | ||
) | ||
} finally { | ||
await remove(P.join('src', 'entry.js')) | ||
} | ||
}, | ||
}, | ||
} |
Oops, something went wrong.