├── generator ├── fully │ ├── index.js │ └── template │ │ └── src │ │ └── cube-ui.js ├── partly │ ├── index.js │ └── template │ │ └── src │ │ └── cube-ui.js ├── theme │ ├── index.js │ └── template │ │ └── src │ │ └── theme.styl ├── config │ └── index.js ├── vw │ └── index.js ├── rem │ └── index.js └── index.js ├── README.md ├── package.json ├── prompts.js ├── index.js ├── LICENSE ├── meta.json └── .gitignore /generator/fully/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.render('./template') 3 | } -------------------------------------------------------------------------------- /generator/partly/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.render('./template') 3 | } -------------------------------------------------------------------------------- /generator/theme/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.render('./template') 3 | } -------------------------------------------------------------------------------- /generator/fully/template/src/cube-ui.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Cube from 'cube-ui' 3 | 4 | Vue.use(Cube) 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-cli-plugin-cube-ui 2 | 3 | cube-ui plugin for vue-cli@3 4 | 5 | ## Usage 6 | 7 | ``` 8 | vue add cube-ui 9 | ``` 10 | 11 | ## Questions 12 | 13 | About prompts, see https://github.com/cube-ui/cube-template/wiki 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-cli-plugin-cube-ui", 3 | "version": "0.2.5", 4 | "main": "index.js", 5 | "dependencies": { 6 | "webpack-post-compile-plugin": "^1.0.0", 7 | "webpack-transform-modules-plugin": "^0.4.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /generator/config/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.extendPackage({ 3 | vue: { 4 | css: { 5 | loaderOptions: { 6 | stylus: { 7 | 'resolve url': true, 8 | import: options.theme ? ['./src/theme'] : [] 9 | } 10 | } 11 | }, 12 | pluginOptions: { 13 | 'cube-ui': { 14 | postCompile: !!options.postCompile, 15 | theme: !!options.theme 16 | } 17 | } 18 | } 19 | }) 20 | } 21 | -------------------------------------------------------------------------------- /generator/vw/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.extendPackage({ 3 | devDependencies: { 4 | 'postcss-px-to-viewport': '^0.0.3' 5 | }, 6 | postcss: { 7 | plugins: { 8 | 'postcss-px-to-viewport': { 9 | viewportWidth: 375, 10 | viewportHeight: 667, 11 | unitPrecision: 5, 12 | viewportUnit: 'vw', 13 | selectorBlackList: [], 14 | minPixelValue: 1, 15 | mediaQuery: false 16 | } 17 | } 18 | } 19 | }) 20 | } -------------------------------------------------------------------------------- /generator/rem/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.extendPackage({ 3 | devDependencies: { 4 | 'postcss-px2rem': '^0.3.0' 5 | } 6 | }) 7 | api.extendPackage({ 8 | postcss: { 9 | plugins: { 10 | 'postcss-px2rem': { 11 | remUnit: 37.5 12 | } 13 | } 14 | } 15 | }) 16 | if (options.amfeFlexible) { 17 | api.extendPackage({ 18 | dependencies: { 19 | 'amfe-flexible': '^2.2.1' 20 | } 21 | }) 22 | api.injectImports(api.entryFile, `import 'amfe-flexible'`) 23 | } 24 | } -------------------------------------------------------------------------------- /prompts.js: -------------------------------------------------------------------------------- 1 | const conf = require('./meta.json') 2 | const questions = Object.keys(conf).map((key) => { 3 | const question = conf[key] 4 | question.name = key 5 | const when = question.when 6 | if (when) { 7 | question.when = function (answers) { 8 | return when.split('&&').every((condition) => { 9 | condition = condition.trim() 10 | const reverse = condition.charAt(0) === '!' 11 | if (reverse) { 12 | condition = condition.slice(1) 13 | } 14 | let val = answers[condition] 15 | if (reverse) { 16 | val = !val 17 | } 18 | return val 19 | }) 20 | } 21 | } 22 | return question 23 | }) 24 | 25 | module.exports = questions -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const PostCompilePlugin = require('webpack-post-compile-plugin') 2 | const TransformModulesPlugin = require('webpack-transform-modules-plugin') 3 | 4 | module.exports = (api, projectOptions) => { 5 | // handle stylus options import path 6 | const imports = projectOptions.css.loaderOptions.stylus.import 7 | imports.forEach((path, index) => { 8 | imports[index] = api.resolve(path) 9 | }) 10 | const cubeUIOpts = projectOptions.pluginOptions && projectOptions.pluginOptions['cube-ui'] || { 11 | postCompile: true 12 | } 13 | if (cubeUIOpts.postCompile) { 14 | // post compile 15 | api.chainWebpack(config => { 16 | const conf = config.toConfig() 17 | config 18 | .plugin('post-compile') 19 | .use(PostCompilePlugin) 20 | }) 21 | } else { 22 | api.chainWebpack(config => { 23 | config 24 | .resolve 25 | .alias 26 | .set('cube-ui', 'cube-ui/lib') 27 | }) 28 | } 29 | // transfrom modules 30 | api.chainWebpack(config => { 31 | config 32 | .plugin('transform-modules') 33 | .use(TransformModulesPlugin) 34 | }) 35 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 cube-ui 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "postCompile": { 3 | "type": "confirm", 4 | "message": "Use post-compile?" 5 | }, 6 | "importType": { 7 | "type": "list", 8 | "message": "Import type", 9 | "choices": [ 10 | { 11 | "name": "partly, import component on demand, which makes the size of imported code lighter", 12 | "value": "partly", 13 | "short": "Partly", 14 | "checked": true 15 | }, 16 | { 17 | "name": "fully, import all the components", 18 | "value": "fully", 19 | "short": "Fully" 20 | } 21 | ] 22 | }, 23 | "theme": { 24 | "when": "postCompile", 25 | "type": "confirm", 26 | "message": "Custom theme?" 27 | }, 28 | "rem": { 29 | "when": "postCompile", 30 | "type": "confirm", 31 | "message": "Use rem layout?", 32 | "default": false 33 | }, 34 | "amfeFlexible": { 35 | "when": "postCompile && rem", 36 | "type": "confirm", 37 | "message": "Use amfe-flexible?" 38 | }, 39 | "vw": { 40 | "when": "postCompile && !rem", 41 | "type": "confirm", 42 | "message": "Use vw layout?", 43 | "default": false 44 | } 45 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | -------------------------------------------------------------------------------- /generator/partly/template/src/cube-ui.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | // By default we import all the components. 4 | // Only reserve the components on demand and remove the rest. 5 | // Style is always required. 6 | import { 7 | /* eslint-disable no-unused-vars */ 8 | Style, 9 | // basic 10 | Button, 11 | Loading, 12 | Tip, 13 | Toolbar, 14 | TabBar, 15 | TabPanels, 16 | // form 17 | Checkbox, 18 | CheckboxGroup, 19 | Checker, 20 | Radio, 21 | RadioGroup, 22 | Input, 23 | Textarea, 24 | Select, 25 | Switch, 26 | Rate, 27 | Validator, 28 | Upload, 29 | Form, 30 | // popup 31 | Popup, 32 | Toast, 33 | Picker, 34 | CascadePicker, 35 | DatePicker, 36 | TimePicker, 37 | SegmentPicker, 38 | Dialog, 39 | ActionSheet, 40 | Drawer, 41 | ImagePreview, 42 | // scroll 43 | Scroll, 44 | Slide, 45 | IndexList, 46 | Swipe, 47 | Sticky, 48 | ScrollNav, 49 | ScrollNavBar 50 | } from 'cube-ui' 51 | 52 | Vue.use(Button) 53 | Vue.use(Loading) 54 | Vue.use(Tip) 55 | Vue.use(Toolbar) 56 | Vue.use(TabBar) 57 | Vue.use(TabPanels) 58 | Vue.use(Checkbox) 59 | Vue.use(CheckboxGroup) 60 | Vue.use(Checker) 61 | Vue.use(Radio) 62 | Vue.use(RadioGroup) 63 | Vue.use(Input) 64 | Vue.use(Textarea) 65 | Vue.use(Select) 66 | Vue.use(Switch) 67 | Vue.use(Rate) 68 | Vue.use(Validator) 69 | Vue.use(Upload) 70 | Vue.use(Form) 71 | Vue.use(Popup) 72 | Vue.use(Toast) 73 | Vue.use(Picker) 74 | Vue.use(CascadePicker) 75 | Vue.use(DatePicker) 76 | Vue.use(TimePicker) 77 | Vue.use(SegmentPicker) 78 | Vue.use(Dialog) 79 | Vue.use(ActionSheet) 80 | Vue.use(Drawer) 81 | Vue.use(ImagePreview) 82 | Vue.use(Scroll) 83 | Vue.use(Slide) 84 | Vue.use(IndexList) 85 | Vue.use(Swipe) 86 | Vue.use(Sticky) 87 | Vue.use(ScrollNav) 88 | Vue.use(ScrollNavBar) 89 | -------------------------------------------------------------------------------- /generator/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (api, options) => { 2 | api.extendPackage({ 3 | dependencies: { 4 | 'cube-ui': '~1.12.15' 5 | } 6 | }) 7 | 8 | api.postProcessFiles(files => { 9 | const entryFile = files[api.entryFile] 10 | const vueImportStr = `from 'vue'` 11 | if (entryFile && entryFile.indexOf(vueImportStr)) { 12 | files[api.entryFile] = entryFile.replace(vueImportStr, vueImportStr + `\nimport './cube-ui'`) 13 | } else { 14 | api.injectImports(api.entryFile, `import './cube-ui'`) 15 | } 16 | }) 17 | 18 | if (api.invoking) { 19 | api.postProcessFiles(files => { 20 | const appFile = files[`src/App.vue`] 21 | if (appFile) { 22 | // TODO 23 | // files[`src/App.vue`] = appFile.replace(/^