├── .gitignore ├── LICENSE ├── README.md ├── meta.js ├── package.json ├── scripts └── update-cube-version.js └── template ├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── README.md ├── build ├── build.js ├── check-versions.js ├── logo.png ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js ├── webpack.prod.conf.js └── webpack.test.conf.js ├── config ├── dev.env.js ├── index.js ├── prod.env.js └── test.env.js ├── index.html ├── package.json ├── src ├── App.vue ├── assets │ └── logo.png ├── components │ └── HelloWorld.vue ├── main.js ├── router │ └── index.js └── theme.styl ├── static └── .gitkeep └── test ├── e2e ├── custom-assertions │ └── elementCount.js ├── nightwatch.conf.js ├── runner.js └── specs │ └── test.js └── unit ├── .eslintrc ├── index.js ├── jest.conf.js ├── karma.conf.js ├── setup.js └── specs └── HelloWorld.spec.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | docs/_book 4 | demo/ 5 | .idea/ 6 | bak/ 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cube-template 2 | 3 | cube-ui template for Vue-cli 4 | 5 | 在 cube-template 中特殊的配置项。 6 | 7 | - Use post-compile? 8 | 9 | 后编译,详细文档 https://didi.github.io/cube-ui/#/zh-CN/docs/post-compile 10 | 11 | - Import type 12 | 13 | 引入类型,可以是: 14 | 15 | - 按需引入(推荐):https://didi.github.io/cube-ui/#/zh-CN/docs/quick-start#cube-按需引入-anchor 16 | - 全部引入:https://didi.github.io/cube-ui/#/zh-CN/docs/quick-start#cube-全部引入-anchor 17 | 18 | - Custom theme? 19 | 20 | 自定义主题,使用后编译的情况下可用;会在 `src/` 目录下创建一个 `theme.styl` 的文件,定义各种变量,参考 https://didi.github.io/cube-ui/#/zh-CN/docs/theme 21 | 22 | - Use rem layout? 23 | 24 | rem 布局,使用后编译的情况下可用;使用 [postcss-px2rem](https://github.com/songsiqi/px2rem-postcss) 插件完成 px 到 rem 的转换,如果要修改基准值,修改 `.postcssrc.js` 文件中的 "remUnit" 的值即可。 25 | 26 | - Use vw layout? 27 | 28 | vw 布局,使用后编译的情况下且不是 rem 布局的情况下可用;使用 [postcss-px-to-viewport](https://github.com/evrone/postcss-px-to-viewport) 插件完成 px 到 vw 的转换。 29 | 30 | - Use amfe-flexible? 31 | 32 | 当使用 rem 布局的时候,可以选择使用 [lib-flexible 2.x](https://github.com/amfe/lib-flexible) 来动态计算更新 rem 的值;当然也可以使用你自定义的 rem 计算方式,但是一定不能动态去需改 viewport,viewport width 只支持为 device-width 的情况 33 | 34 | > **使用rem/vw布局时**: 如果你的 remUnit 不能设置为 37.5,或者 viewportWidth 不是 375,可以使用 [postcss-design-convert](https://www.npmjs.com/package/postcss-design-convert) 插件完成相应转换。 35 | 36 | All cube-template special options. 37 | 38 | - Use post-compile? 39 | 40 | About post-compile https://didi.github.io/cube-ui/#/en-US/docs/post-compile 41 | 42 | - Import type 43 | 44 | Partly: https://didi.github.io/cube-ui/#/en-US/docs/quick-start#cube-Importondemand-anchor 45 | Fully: https://didi.github.io/cube-ui/#/en-US/docs/quick-start#cube-Fullyimport-anchor 46 | 47 | - Custom theme? 48 | 49 | https://didi.github.io/cube-ui/#/en-US/docs/theme 50 | 51 | - Use rem layout? 52 | 53 | Use rem to layout Page, if you want to change the basic rem unit value, then just modify the `remUnit` value in file `.postcssrc.js`. 54 | 55 | - Use vw layout? 56 | 57 | Use vw to layout Page, this use [postcss-px-to-viewport](https://github.com/evrone/postcss-px-to-viewport) plugin to process px to vw. 58 | 59 | - Use amfe-flexible? 60 | 61 | Use https://github.com/amfe/lib-flexible to set `rem` value 62 | -------------------------------------------------------------------------------- /meta.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | 4 | function sortObject(object) { 5 | // Based on https://github.com/yarnpkg/yarn/blob/v1.3.2/src/config.js#L79-L85 6 | const sortedObject = {}; 7 | Object.keys(object).sort().forEach(item => { 8 | sortedObject[item] = object[item]; 9 | }); 10 | return sortedObject; 11 | } 12 | 13 | module.exports = { 14 | "helpers": { 15 | "if_or": function (v1, v2, options) { 16 | if (v1 || v2) { 17 | return options.fn(this); 18 | } 19 | 20 | return options.inverse(this); 21 | } 22 | }, 23 | "prompts": { 24 | "name": { 25 | "type": "string", 26 | "required": true, 27 | "message": "Project name" 28 | }, 29 | "description": { 30 | "type": "string", 31 | "required": false, 32 | "message": "Project description", 33 | "default": "A Vue.js project" 34 | }, 35 | "author": { 36 | "type": "string", 37 | "message": "Author" 38 | }, 39 | "build": { 40 | "type": "list", 41 | "message": "Vue build", 42 | "choices": [ 43 | { 44 | "name": "Runtime + Compiler: recommended for most users", 45 | "value": "standalone", 46 | "short": "standalone" 47 | }, 48 | { 49 | "name": "Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere", 50 | "value": "runtime", 51 | "short": "runtime" 52 | } 53 | ] 54 | }, 55 | "postCompile": { 56 | "type": "confirm", 57 | "message": "Use post-compile?" 58 | }, 59 | "importType": { 60 | "type": "list", 61 | "message": "Import type", 62 | "choices": [ 63 | { 64 | "name": "partly, import component on demand, which makes the size of imported code lighter", 65 | "value": "partly", 66 | "short": "Partly" 67 | }, 68 | { 69 | "name": "fully, import all the components", 70 | "value": "fully", 71 | "short": "Fully" 72 | } 73 | ] 74 | }, 75 | "theme": { 76 | "when": "postCompile", 77 | "type": "confirm", 78 | "message": "Custom theme?" 79 | }, 80 | "rem": { 81 | "when": "postCompile", 82 | "type": "confirm", 83 | "message": "Use rem layout?", 84 | "default": false 85 | }, 86 | "amfeFlexible": { 87 | "when": "postCompile && rem", 88 | "type": "confirm", 89 | "message": "Use amfe-flexible?" 90 | }, 91 | "vw": { 92 | "when": "postCompile && !rem", 93 | "type": "confirm", 94 | "message": "Use vw layout?", 95 | "default": false 96 | }, 97 | "router": { 98 | "type": "confirm", 99 | "message": "Install vue-router?" 100 | }, 101 | "lint": { 102 | "type": "confirm", 103 | "message": "Use ESLint to lint your code?" 104 | }, 105 | "lintConfig": { 106 | "when": "lint", 107 | "type": "list", 108 | "message": "Pick an ESLint preset", 109 | "choices": [ 110 | { 111 | "name": "Standard (https://github.com/standard/standard)", 112 | "value": "standard", 113 | "short": "Standard" 114 | }, 115 | { 116 | "name": "Airbnb (https://github.com/airbnb/javascript)", 117 | "value": "airbnb", 118 | "short": "Airbnb" 119 | }, 120 | { 121 | "name": "none (configure it yourself)", 122 | "value": "none", 123 | "short": "none" 124 | } 125 | ] 126 | }, 127 | "unit": { 128 | "type": "confirm", 129 | "message": "Set up unit tests" 130 | }, 131 | "runner": { 132 | "when": "unit", 133 | "type": "list", 134 | "message": "Pick a test runner", 135 | "choices": [ 136 | { 137 | "name": "Jest", 138 | "value": "jest", 139 | "short": "jest" 140 | }, 141 | { 142 | "name": "Karma and Mocha", 143 | "value": "karma", 144 | "short": "karma" 145 | }, 146 | { 147 | "name": "none (configure it yourself)", 148 | "value": "noTest", 149 | "short": "noTest" 150 | } 151 | ] 152 | }, 153 | "e2e": { 154 | "type": "confirm", 155 | "message": "Setup e2e tests with Nightwatch?" 156 | } 157 | }, 158 | "filters": { 159 | ".eslintrc.js": "lint", 160 | ".eslintignore": "lint", 161 | "config/test.env.js": "unit || e2e", 162 | "build/webpack.test.conf.js": "unit && runner === 'karma'", 163 | "test/unit/**/*": "unit", 164 | "test/unit/index.js": "unit && runner === 'karma'", 165 | "test/unit/jest.conf.js": "unit && runner === 'jest'", 166 | "test/unit/karma.conf.js": "unit && runner === 'karma'", 167 | "test/unit/specs/index.js": "unit && runner === 'karma'", 168 | "test/unit/setup.js": "unit && runner === 'jest'", 169 | "test/e2e/**/*": "e2e", 170 | "src/router/**/*": "router", 171 | "src/theme.styl": "postCompile && theme" 172 | }, 173 | "complete": function (data) { 174 | const packageJsonFile = path.join( 175 | data.inPlace ? "" : data.destDirName, 176 | "package.json" 177 | ); 178 | const packageJson = JSON.parse(fs.readFileSync(packageJsonFile)); 179 | packageJson.devDependencies = sortObject(packageJson.devDependencies); 180 | packageJson.dependencies = sortObject(packageJson.dependencies); 181 | fs.writeFileSync( 182 | packageJsonFile, 183 | JSON.stringify(packageJson, null, 2) + "\n" 184 | ); 185 | 186 | const message = `To get started:\n\n ${data.inPlace ? '' : `cd ${data.destDirName}\n `}npm install\n npm run dev\n\nYeah,let's make an awesome app via cube-ui!`; 187 | console.log("\n" + message.split(/\r?\n/g).map(line => " " + line).join("\n")); 188 | } 189 | }; 190 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-cli-template-cube-ui", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "description": "cube-ui template base on webpack for Vue-cli", 6 | "scripts": { 7 | "update": "node ./scripts/update-cube-version.js", 8 | "demo": "rm -rf demo && vue init ./ demo" 9 | }, 10 | "devDependencies": { 11 | "vue-cli": "^2.8.1" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/update-cube-version.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | const https = require('https') 4 | 5 | const options = { 6 | hostname: 'registry.npmjs.org', 7 | port: 443, 8 | path: '/cube-ui', 9 | method: 'GET' 10 | } 11 | 12 | // Get latest version of cube-ui 13 | const req = https.request(options, (res) => { 14 | if (res.statusCode !== 200) { 15 | console.error(`Request Failed. Status Code: ${statusCode}`) 16 | res.resume() 17 | 18 | return 19 | } 20 | 21 | let rawData = '' 22 | res.on('data', (data) => { 23 | rawData += data 24 | }) 25 | res.on('end', () => { 26 | const parsedData = JSON.parse(rawData) 27 | const version = parsedData['dist-tags'].latest 28 | replaceVersion(version) 29 | }) 30 | }) 31 | 32 | req.on('error', (e) => { 33 | console.error(e); 34 | }) 35 | 36 | req.end() 37 | 38 | function replaceVersion(version) { 39 | const packagePath = path.resolve(__dirname, '../template/package.json') 40 | let content = fs.readFileSync(packagePath).toString() 41 | content = content.replace(/(?<="cube-ui": "~)\d+\.\d+\.\d+(?=")/, version) 42 | fs.writeFileSync(packagePath, content) 43 | } 44 | -------------------------------------------------------------------------------- /template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false 5 | }], 6 | "stage-2" 7 | ], 8 | "plugins": [ 9 | "transform-runtime" 10 | ]{{#if_or unit e2e}}, 11 | "env": { 12 | "test": { 13 | "presets": ["env", "stage-2"]{{#if_eq runner "karma"}}, 14 | "plugins": ["istanbul"]{{/if_eq}}{{#if_eq runner "jest"}}, 15 | "plugins": ["transform-es2015-modules-commonjs", "dynamic-import-node"]{{/if_eq}} 16 | } 17 | }{{/if_or}} 18 | } 19 | -------------------------------------------------------------------------------- /template/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /template/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | {{#unit}} 6 | /test/unit/coverage/ 7 | {{/unit}} 8 | -------------------------------------------------------------------------------- /template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | {{#if_eq lintConfig "standard"}} 13 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 14 | extends: 'standard', 15 | {{/if_eq}} 16 | {{#if_eq lintConfig "airbnb"}} 17 | extends: 'airbnb-base', 18 | {{/if_eq}} 19 | // required to lint *.vue files 20 | plugins: [ 21 | 'html' 22 | ], 23 | {{#if_eq lintConfig "airbnb"}} 24 | // check if imports actually resolve 25 | settings: { 26 | 'import/resolver': { 27 | webpack: { 28 | config: 'build/webpack.base.conf.js' 29 | } 30 | } 31 | }, 32 | {{/if_eq}} 33 | // add your custom rules here 34 | rules: { 35 | {{#if_eq lintConfig "standard"}} 36 | // allow async-await 37 | 'generator-star-spacing': 'off', 38 | {{/if_eq}} 39 | {{#if_eq lintConfig "airbnb"}} 40 | // don't require .vue extension when importing 41 | 'import/extensions': ['error', 'always', { 42 | js: 'never', 43 | vue: 'never' 44 | }], 45 | // allow optionalDependencies 46 | 'import/no-extraneous-dependencies': ['error', { 47 | optionalDependencies: ['test/unit/index.js'] 48 | }], 49 | {{/if_eq}} 50 | // allow debugger during development 51 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | {{#unit}} 8 | /test/unit/coverage/ 9 | {{/unit}} 10 | {{#e2e}} 11 | /test/e2e/reports/ 12 | selenium-debug.log 13 | {{/e2e}} 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | -------------------------------------------------------------------------------- /template/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserslist" field in package.json 6 | "postcss-import": {}, 7 | "autoprefixer": {}{{#rem}}, 8 | "postcss-px2rem": { 9 | "remUnit": 37.5 10 | }{{/rem}}{{#vw}}, 11 | "postcss-px-to-viewport": { 12 | "viewportWidth": 375, 13 | "viewportHeight": 667, 14 | "unitPrecision": 5, 15 | "viewportUnit": "vw", 16 | "selectorBlackList": [], 17 | "minPixelValue": 1, 18 | "mediaQuery": false 19 | }{{/vw}} 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # {{ name }} 2 | 3 | > {{ description }} 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | {{#unit}} 20 | 21 | # run unit tests 22 | npm run unit 23 | {{/unit}} 24 | {{#e2e}} 25 | 26 | # run e2e tests 27 | npm run e2e 28 | {{/e2e}} 29 | {{#if_or unit e2e}} 30 | 31 | # run all tests 32 | npm test 33 | {{/if_or}} 34 | ``` 35 | 36 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 37 | -------------------------------------------------------------------------------- /template/build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const ora = require('ora') 7 | const rm = require('rimraf') 8 | const path = require('path') 9 | const chalk = require('chalk') 10 | const webpack = require('webpack') 11 | const config = require('../config') 12 | const webpackConfig = require('./webpack.prod.conf') 13 | 14 | const spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 18 | if (err) throw err 19 | webpack(webpackConfig, (err, stats) => { 20 | spinner.stop() 21 | if (err) throw err 22 | process.stdout.write(stats.toString({ 23 | colors: true, 24 | modules: false, 25 | children: false, 26 | chunks: false, 27 | chunkModules: false 28 | }) + '\n\n') 29 | 30 | if (stats.hasErrors()) { 31 | console.log(chalk.red(' Build failed with errors.\n')) 32 | process.exit(1) 33 | } 34 | 35 | console.log(chalk.cyan(' Build complete.\n')) 36 | console.log(chalk.yellow( 37 | ' Tip: built files are meant to be served over an HTTP server.\n' + 38 | ' Opening index.html over file:// won\'t work.\n' 39 | )) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /template/build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | 7 | function exec (cmd) { 8 | return require('child_process').execSync(cmd).toString().trim() 9 | } 10 | 11 | const versionRequirements = [ 12 | { 13 | name: 'node', 14 | currentVersion: semver.clean(process.version), 15 | versionRequirement: packageConfig.engines.node 16 | } 17 | ] 18 | 19 | if (shell.which('npm')) { 20 | versionRequirements.push({ 21 | name: 'npm', 22 | currentVersion: exec('npm --version'), 23 | versionRequirement: packageConfig.engines.npm 24 | }) 25 | } 26 | 27 | module.exports = function () { 28 | const warnings = [] 29 | 30 | for (let i = 0; i < versionRequirements.length; i++) { 31 | const mod = versionRequirements[i] 32 | 33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 34 | warnings.push(mod.name + ': ' + 35 | chalk.red(mod.currentVersion) + ' should be ' + 36 | chalk.green(mod.versionRequirement) 37 | ) 38 | } 39 | } 40 | 41 | if (warnings.length) { 42 | console.log('') 43 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 44 | console.log() 45 | 46 | for (let i = 0; i < warnings.length; i++) { 47 | const warning = warnings[i] 48 | console.log(' ' + warning) 49 | } 50 | 51 | console.log() 52 | process.exit(1) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /template/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cube-ui/cube-template/2386c2c68e1f996b0f463a8abc2827b7a896670e/template/build/logo.png -------------------------------------------------------------------------------- /template/build/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const config = require('../config') 4 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 5 | const packageConfig = require('../package.json') 6 | 7 | exports.assetsPath = function (_path) { 8 | const assetsSubDirectory = process.env.NODE_ENV === 'production' 9 | ? config.build.assetsSubDirectory 10 | : config.dev.assetsSubDirectory 11 | 12 | return path.posix.join(assetsSubDirectory, _path) 13 | } 14 | 15 | exports.cssLoaders = function (options) { 16 | options = options || {} 17 | 18 | const cssLoader = { 19 | loader: 'css-loader', 20 | options: { 21 | sourceMap: options.sourceMap 22 | } 23 | } 24 | 25 | const postcssLoader = { 26 | loader: 'postcss-loader', 27 | options: { 28 | sourceMap: options.sourceMap 29 | } 30 | } 31 | 32 | // generate loader string to be used with extract text plugin 33 | function generateLoaders (loader, loaderOptions) { 34 | const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] 35 | 36 | if (loader) { 37 | loaders.push({ 38 | loader: loader + '-loader', 39 | options: Object.assign({}, loaderOptions, { 40 | sourceMap: options.sourceMap 41 | }) 42 | }) 43 | } 44 | 45 | // Extract CSS when that option is specified 46 | // (which is the case during production build) 47 | if (options.extract) { 48 | return ExtractTextPlugin.extract({ 49 | use: loaders, 50 | fallback: 'vue-style-loader' 51 | }) 52 | } else { 53 | return ['vue-style-loader'].concat(loaders) 54 | } 55 | } 56 | 57 | {{#postCompile}} 58 | const stylusOptions = { 59 | 'resolve url': true{{#theme}}, 60 | 'import': [path.resolve(__dirname, '../src/theme')]{{/theme}} 61 | } 62 | {{/postCompile}} 63 | 64 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 65 | return { 66 | css: generateLoaders(), 67 | postcss: generateLoaders(), 68 | less: generateLoaders('less'), 69 | sass: generateLoaders('sass', { indentedSyntax: true }), 70 | scss: generateLoaders('sass'), 71 | stylus: generateLoaders('stylus'{{#postCompile}}, stylusOptions{{/postCompile}}), 72 | styl: generateLoaders('stylus'{{#postCompile}}, stylusOptions{{/postCompile}}) 73 | } 74 | } 75 | 76 | // Generate loaders for standalone style files (outside of .vue) 77 | exports.styleLoaders = function (options) { 78 | const output = [] 79 | const loaders = exports.cssLoaders(options) 80 | 81 | for (const extension in loaders) { 82 | const loader = loaders[extension] 83 | output.push({ 84 | test: new RegExp('\\.' + extension + '$'), 85 | use: loader 86 | }) 87 | } 88 | 89 | return output 90 | } 91 | 92 | exports.createNotifierCallback = () => { 93 | const notifier = require('node-notifier') 94 | 95 | return (severity, errors) => { 96 | if (severity !== 'error') return 97 | 98 | const error = errors[0] 99 | const filename = error.file && error.file.split('!').pop() 100 | 101 | notifier.notify({ 102 | title: packageConfig.name, 103 | message: severity + ': ' + error.name, 104 | subtitle: filename || '', 105 | icon: path.join(__dirname, 'logo.png') 106 | }) 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /template/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /template/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const config = require('../config') 5 | const vueLoaderConfig = require('./vue-loader.conf') 6 | const TransformModulesPlugin = require('webpack-transform-modules-plugin') 7 | {{#postCompile}} 8 | const PostCompilePlugin = require('webpack-post-compile-plugin') 9 | {{/postCompile}} 10 | 11 | function resolve (dir) { 12 | return path.join(__dirname, '..', dir) 13 | } 14 | 15 | const createLintingRule = () => ({ 16 | test: /\.(js|vue)$/, 17 | loader: 'eslint-loader', 18 | enforce: 'pre', 19 | include: [resolve('src'), resolve('test')], 20 | options: { 21 | formatter: require('eslint-friendly-formatter'), 22 | emitWarning: !config.dev.showEslintErrorsInOverlay 23 | } 24 | }) 25 | 26 | module.exports = { 27 | context: path.resolve(__dirname, '../'), 28 | entry: { 29 | app: './src/main.js' 30 | }, 31 | output: { 32 | path: config.build.assetsRoot, 33 | filename: '[name].js', 34 | publicPath: process.env.NODE_ENV === 'production' 35 | ? config.build.assetsPublicPath 36 | : config.dev.assetsPublicPath 37 | }, 38 | resolve: { 39 | extensions: ['.js', '.vue', '.json'], 40 | alias: { 41 | {{#if_eq build "standalone"}} 42 | 'vue$': 'vue/dist/vue.esm.js', 43 | {{/if_eq}} 44 | {{#unless postCompile}} 45 | 'cube-ui': 'cube-ui/lib', 46 | {{/unless}} 47 | '@': resolve('src'), 48 | } 49 | }, 50 | module: { 51 | rules: [ 52 | {{#lint}} 53 | ...(config.dev.useEslint ? [createLintingRule()] : []), 54 | {{/lint}} 55 | { 56 | test: /\.vue$/, 57 | loader: 'vue-loader', 58 | options: vueLoaderConfig 59 | }, 60 | { 61 | test: /\.js$/, 62 | loader: 'babel-loader', 63 | include: [resolve('src'), resolve('test')] 64 | }, 65 | { 66 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 67 | loader: 'url-loader', 68 | options: { 69 | limit: 10000, 70 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 71 | } 72 | }, 73 | { 74 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 75 | loader: 'url-loader', 76 | options: { 77 | limit: 10000, 78 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 79 | } 80 | }, 81 | { 82 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 83 | loader: 'url-loader', 84 | options: { 85 | limit: 10000, 86 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 87 | } 88 | } 89 | ] 90 | }, 91 | node: { 92 | // prevent webpack from injecting useless setImmediate polyfill because Vue 93 | // source contains it (although only uses it if it's native). 94 | setImmediate: false, 95 | // prevent webpack from injecting mocks to Node native modules 96 | // that does not make sense for the client 97 | dgram: 'empty', 98 | fs: 'empty', 99 | net: 'empty', 100 | tls: 'empty', 101 | child_process: 'empty' 102 | }, 103 | plugins: [ 104 | {{#postCompile}}new PostCompilePlugin(), 105 | {{/postCompile}}new TransformModulesPlugin() 106 | ] 107 | } 108 | -------------------------------------------------------------------------------- /template/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const webpack = require('webpack') 4 | const config = require('../config') 5 | const merge = require('webpack-merge') 6 | const baseWebpackConfig = require('./webpack.base.conf') 7 | const HtmlWebpackPlugin = require('html-webpack-plugin') 8 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 9 | const portfinder = require('portfinder') 10 | 11 | const HOST = process.env.HOST 12 | const PORT = process.env.PORT && Number(process.env.PORT) 13 | 14 | const devWebpackConfig = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: config.dev.devtool, 20 | 21 | // these devServer options should be customized in /config/index.js 22 | devServer: { 23 | clientLogLevel: 'warning', 24 | historyApiFallback: true, 25 | hot: true, 26 | compress: true, 27 | host: HOST || config.dev.host, 28 | port: PORT || config.dev.port, 29 | open: config.dev.autoOpenBrowser, 30 | overlay: config.dev.errorOverlay 31 | ? { warnings: false, errors: true } 32 | : false, 33 | publicPath: config.dev.assetsPublicPath, 34 | proxy: config.dev.proxyTable, 35 | quiet: true, // necessary for FriendlyErrorsPlugin 36 | watchOptions: { 37 | poll: config.dev.poll, 38 | } 39 | }, 40 | plugins: [ 41 | new webpack.DefinePlugin({ 42 | 'process.env': require('../config/dev.env') 43 | }), 44 | new webpack.HotModuleReplacementPlugin(), 45 | new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. 46 | new webpack.NoEmitOnErrorsPlugin(), 47 | // https://github.com/ampedandwired/html-webpack-plugin 48 | new HtmlWebpackPlugin({ 49 | filename: 'index.html', 50 | template: 'index.html', 51 | inject: true 52 | }), 53 | ] 54 | }) 55 | 56 | module.exports = new Promise((resolve, reject) => { 57 | portfinder.basePort = process.env.PORT || config.dev.port 58 | portfinder.getPort((err, port) => { 59 | if (err) { 60 | reject(err) 61 | } else { 62 | // publish the new Port, necessary for e2e tests 63 | process.env.PORT = port 64 | // add port to devServer config 65 | devWebpackConfig.devServer.port = port 66 | 67 | // Add FriendlyErrorsPlugin 68 | devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ 69 | compilationSuccessInfo: { 70 | messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], 71 | }, 72 | onErrors: config.dev.notifyOnErrors 73 | ? utils.createNotifierCallback() 74 | : undefined 75 | })) 76 | 77 | resolve(devWebpackConfig) 78 | } 79 | }) 80 | }) 81 | -------------------------------------------------------------------------------- /template/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const webpack = require('webpack') 5 | const config = require('../config') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 12 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 13 | 14 | const env = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing' 15 | ? require('../config/test.env') 16 | : {{/if_or}}require('../config/prod.env') 17 | 18 | const webpackConfig = merge(baseWebpackConfig, { 19 | module: { 20 | rules: utils.styleLoaders({ 21 | sourceMap: config.build.productionSourceMap, 22 | extract: true, 23 | usePostCSS: true 24 | }) 25 | }, 26 | devtool: config.build.productionSourceMap ? config.build.devtool : false, 27 | output: { 28 | path: config.build.assetsRoot, 29 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 30 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 31 | }, 32 | plugins: [ 33 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 34 | new webpack.DefinePlugin({ 35 | 'process.env': env 36 | }), 37 | new UglifyJsPlugin({ 38 | uglifyOptions: { 39 | compress: { 40 | warnings: false 41 | } 42 | }, 43 | sourceMap: config.build.productionSourceMap, 44 | parallel: true 45 | }), 46 | // extract css into its own file 47 | new ExtractTextPlugin({ 48 | filename: utils.assetsPath('css/[name].[contenthash].css'), 49 | // set the following option to `true` if you want to extract CSS from 50 | // codesplit chunks into this main css file as well. 51 | // This will result in *all* of your app's CSS being loaded upfront. 52 | allChunks: false, 53 | }), 54 | // Compress extracted CSS. We are using this plugin so that possible 55 | // duplicated CSS from different components can be deduped. 56 | new OptimizeCSSPlugin({ 57 | cssProcessorOptions: config.build.productionSourceMap 58 | ? { safe: true, map: { inline: false } } 59 | : { safe: true } 60 | }), 61 | // generate dist index.html with correct asset hash for caching. 62 | // you can customize output by editing /index.html 63 | // see https://github.com/ampedandwired/html-webpack-plugin 64 | new HtmlWebpackPlugin({ 65 | filename: {{#if_or unit e2e}}process.env.NODE_ENV === 'testing' 66 | ? 'index.html' 67 | : {{/if_or}}config.build.index, 68 | template: 'index.html', 69 | inject: true, 70 | minify: { 71 | removeComments: true, 72 | collapseWhitespace: true, 73 | removeAttributeQuotes: true 74 | // more options: 75 | // https://github.com/kangax/html-minifier#options-quick-reference 76 | }, 77 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 78 | chunksSortMode: 'dependency' 79 | }), 80 | // keep module.id stable when vender modules does not change 81 | new webpack.HashedModuleIdsPlugin(), 82 | // enable scope hoisting 83 | new webpack.optimize.ModuleConcatenationPlugin(), 84 | // split vendor js into its own file 85 | new webpack.optimize.CommonsChunkPlugin({ 86 | name: 'vendor', 87 | minChunks (module) { 88 | // any required modules inside node_modules are extracted to vendor 89 | return ( 90 | module.resource && 91 | /\.js$/.test(module.resource) && 92 | module.resource.indexOf( 93 | path.join(__dirname, '../node_modules') 94 | ) === 0 95 | ) 96 | } 97 | }), 98 | // extract webpack runtime and module manifest to its own file in order to 99 | // prevent vendor hash from being updated whenever app bundle is updated 100 | new webpack.optimize.CommonsChunkPlugin({ 101 | name: 'manifest', 102 | minChunks: Infinity 103 | }), 104 | // This instance extracts shared chunks from code splitted chunks and bundles them 105 | // in a separate chunk, similar to the vendor chunk 106 | // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk 107 | new webpack.optimize.CommonsChunkPlugin({ 108 | name: 'app', 109 | async: 'vendor-async', 110 | children: true, 111 | minChunks: 3 112 | }), 113 | 114 | // copy custom static assets 115 | new CopyWebpackPlugin([ 116 | { 117 | from: path.resolve(__dirname, '../static'), 118 | to: config.build.assetsSubDirectory, 119 | ignore: ['.*'] 120 | } 121 | ]) 122 | ] 123 | }) 124 | 125 | if (config.build.productionGzip) { 126 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 127 | 128 | webpackConfig.plugins.push( 129 | new CompressionWebpackPlugin({ 130 | asset: '[path].gz[query]', 131 | algorithm: 'gzip', 132 | test: new RegExp( 133 | '\\.(' + 134 | config.build.productionGzipExtensions.join('|') + 135 | ')$' 136 | ), 137 | threshold: 10240, 138 | minRatio: 0.8 139 | }) 140 | ) 141 | } 142 | 143 | if (config.build.bundleAnalyzerReport) { 144 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 145 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 146 | } 147 | 148 | module.exports = webpackConfig 149 | -------------------------------------------------------------------------------- /template/build/webpack.test.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // This is the webpack config used for unit tests. 3 | 4 | const utils = require('./utils') 5 | const webpack = require('webpack') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | 9 | const webpackConfig = merge(baseWebpackConfig, { 10 | // use inline sourcemap for karma-sourcemap-loader 11 | module: { 12 | rules: utils.styleLoaders() 13 | }, 14 | devtool: '#inline-source-map', 15 | resolveLoader: { 16 | alias: { 17 | // necessary to to make lang="scss" work in test when using vue-loader's ?inject option 18 | // see discussion at https://github.com/vuejs/vue-loader/issues/724 19 | 'scss-loader': 'sass-loader' 20 | } 21 | }, 22 | plugins: [ 23 | new webpack.DefinePlugin({ 24 | 'process.env': require('../config/test.env') 25 | }) 26 | ] 27 | }) 28 | 29 | // no need for app entry during tests 30 | delete webpackConfig.entry 31 | 32 | module.exports = webpackConfig 33 | -------------------------------------------------------------------------------- /template/config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /template/config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.2.5 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: {}, 14 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 18 | autoOpenBrowser: false, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | // Use Eslint Loader? 24 | // If true, your code will be linted during bundling and 25 | // linting errors and warnings will be shown in the console. 26 | useEslint: true, 27 | // If true, eslint errors and warnings will also be shown in the error overlay 28 | // in the browser. 29 | showEslintErrorsInOverlay: false, 30 | 31 | /** 32 | * Source Maps 33 | */ 34 | 35 | // https://webpack.js.org/configuration/devtool/#development 36 | devtool: 'eval-source-map', 37 | 38 | // If you have problems debugging vue-files in devtools, 39 | // set this to false - it *may* help 40 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 41 | cacheBusting: true, 42 | 43 | // CSS Sourcemaps off by default because relative paths are "buggy" 44 | // with this option, according to the CSS-Loader README 45 | // (https://github.com/webpack/css-loader#sourcemaps) 46 | // In our experience, they generally work as expected, 47 | // just be aware of this issue when enabling this option. 48 | cssSourceMap: false, 49 | }, 50 | 51 | build: { 52 | // Template for index.html 53 | index: path.resolve(__dirname, '../dist/index.html'), 54 | 55 | // Paths 56 | assetsRoot: path.resolve(__dirname, '../dist'), 57 | assetsSubDirectory: 'static', 58 | assetsPublicPath: '/', 59 | 60 | /** 61 | * Source Maps 62 | */ 63 | 64 | productionSourceMap: true, 65 | // https://webpack.js.org/configuration/devtool/#production 66 | devtool: '#source-map', 67 | 68 | // Gzip off by default as many popular static hosts such as 69 | // Surge or Netlify already gzip all static assets for you. 70 | // Before setting to `true`, make sure to: 71 | // npm install --save-dev compression-webpack-plugin 72 | productionGzip: false, 73 | productionGzipExtensions: ['js', 'css'], 74 | 75 | // Run the build command with an extra argument to 76 | // View the bundle analyzer report after build finishes: 77 | // `npm run build --report` 78 | // Set to `true` or `false` to always turn it on or off 79 | bundleAnalyzerReport: process.env.npm_config_report 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /template/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /template/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ name }} 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{ name }}", 3 | "version": "1.0.0", 4 | "description": "{{ description }}", 5 | "author": "{{ author }}", 6 | "private": true, 7 | "scripts": { 8 | "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", 9 | "start": "npm run dev", 10 | {{#if_eq runner "jest"}} 11 | "unit": "jest --config test/unit/jest.conf.js --coverage", 12 | {{/if_eq}} 13 | {{#if_eq runner "karma"}} 14 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", 15 | {{/if_eq}} 16 | {{#e2e}} 17 | "e2e": "node test/e2e/runner.js", 18 | {{/e2e}} 19 | {{#if_or unit e2e}} 20 | "test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}", 21 | {{/if_or}} 22 | {{#lint}} 23 | "lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}", 24 | {{/lint}} 25 | "build": "node build/build.js" 26 | }, 27 | {{#postCompile}} 28 | "transformModules": { 29 | "cube-ui": { 30 | "transform": "cube-ui/src/modules/${member}", 31 | "kebabCase": true 32 | } 33 | }, 34 | {{/postCompile}} 35 | {{#unless postCompile}} 36 | "transformModules": { 37 | "cube-ui": { 38 | "transform": "cube-ui/lib/${member}", 39 | "kebabCase": true, 40 | "style": { 41 | "ignore": ["create-api", "better-scroll", "locale"] 42 | } 43 | } 44 | }, 45 | {{/unless}} 46 | "dependencies": { 47 | "vue": "^2.5.2",{{#router}} 48 | "vue-router": "^3.0.1",{{/router}} 49 | "cube-ui": "~1.12.15"{{#amfeFlexible}}, 50 | "amfe-flexible": "^2.2.1" 51 | {{/amfeFlexible}} 52 | }, 53 | "devDependencies": { 54 | "prettier": "^1.12.1", 55 | {{#lint}} 56 | "babel-eslint": "^7.1.1", 57 | "eslint": "^3.19.0", 58 | "eslint-friendly-formatter": "^3.0.0", 59 | "eslint-loader": "^1.7.1", 60 | "eslint-plugin-html": "^3.0.0", 61 | {{#if_eq lintConfig "standard"}} 62 | "eslint-config-standard": "^10.2.1", 63 | "eslint-plugin-promise": "^3.4.0", 64 | "eslint-plugin-standard": "^3.0.1", 65 | "eslint-plugin-import": "^2.7.0", 66 | "eslint-plugin-node": "^5.2.0", 67 | {{/if_eq}} 68 | {{#if_eq lintConfig "airbnb"}} 69 | "eslint-config-airbnb-base": "^11.3.0", 70 | "eslint-import-resolver-webpack": "^0.8.3", 71 | "eslint-plugin-import": "^2.7.0", 72 | {{/if_eq}} 73 | {{/lint}} 74 | {{#if_eq runner "jest"}} 75 | "babel-jest": "^21.0.2", 76 | "babel-plugin-dynamic-import-node": "^1.2.0", 77 | "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", 78 | "jest": "^21.2.0", 79 | "jest-serializer-vue": "^0.3.0", 80 | "vue-jest": "^1.0.2", 81 | {{/if_eq}} 82 | {{#if_eq runner "karma"}} 83 | "cross-env": "^5.0.1", 84 | "karma": "^1.4.1", 85 | "karma-coverage": "^1.1.1", 86 | "karma-mocha": "^1.3.0", 87 | "karma-phantomjs-launcher": "^1.0.2", 88 | "karma-phantomjs-shim": "^1.4.0", 89 | "karma-sinon-chai": "^1.3.1", 90 | "karma-sourcemap-loader": "^0.3.7", 91 | "karma-spec-reporter": "0.0.31", 92 | "karma-webpack": "^2.0.2", 93 | "mocha": "^3.2.0", 94 | "chai": "^4.1.2", 95 | "sinon": "^4.0.0", 96 | "sinon-chai": "^2.8.0", 97 | "inject-loader": "^3.0.0", 98 | "babel-plugin-istanbul": "^4.1.1", 99 | "phantomjs-prebuilt": "^2.1.14", 100 | {{/if_eq}} 101 | {{#e2e}} 102 | "babel-register": "^6.22.0", 103 | "chromedriver": "^2.27.2", 104 | "cross-spawn": "^5.0.1", 105 | "nightwatch": "^0.9.12", 106 | "selenium-server": "^3.0.1", 107 | {{/e2e}} 108 | "autoprefixer": "^7.1.2", 109 | "babel-core": "^6.22.1", 110 | "babel-loader": "^7.1.1", 111 | "babel-plugin-transform-runtime": "^6.22.0", 112 | "babel-preset-env": "^1.3.2", 113 | "babel-preset-stage-2": "^6.22.0", 114 | "chalk": "^2.0.1", 115 | "copy-webpack-plugin": "^4.5.0", 116 | "css-loader": "^0.28.0", 117 | "eventsource-polyfill": "^0.9.6", 118 | "extract-text-webpack-plugin": "^3.0.0", 119 | "file-loader": "^1.1.4", 120 | "friendly-errors-webpack-plugin": "^1.6.1", 121 | "html-webpack-plugin": "^2.30.1", 122 | "webpack-bundle-analyzer": "^2.9.0", 123 | "node-notifier": "^5.1.2", 124 | "postcss-import": "^11.0.0", 125 | "postcss-loader": "^2.0.8", 126 | "semver": "^5.3.0", 127 | "shelljs": "^0.7.6", 128 | "optimize-css-assets-webpack-plugin": "^3.2.0", 129 | "ora": "^1.2.0", 130 | "rimraf": "^2.6.0", 131 | "uglifyjs-webpack-plugin": "^1.1.1", 132 | "url-loader": "^0.5.8", 133 | "vue-loader": "^13.3.0", 134 | "vue-style-loader": "^3.0.1", 135 | "vue-template-compiler": "^2.5.2", 136 | "portfinder": "^1.0.13", 137 | "webpack": "^3.6.0", 138 | "webpack-dev-server": "^2.9.1", 139 | "webpack-merge": "^4.1.0", 140 | {{#postCompile}} 141 | "stylus": "^0.54.5", 142 | "stylus-loader": "^2.1.1", 143 | "webpack-post-compile-plugin": "^1.0.0", 144 | {{/postCompile}} 145 | {{#rem}} 146 | "postcss-px2rem": "^0.3.0", 147 | {{/rem}} 148 | {{#vw}} 149 | "postcss-px-to-viewport": "^0.0.3", 150 | {{/vw}} 151 | "webpack-transform-modules-plugin": "^0.4.3" 152 | }, 153 | "engines": { 154 | "node": ">= 4.0.0", 155 | "npm": ">= 3.0.0" 156 | }, 157 | "browserslist": [ 158 | "> 1%", 159 | "not ie <= 11", 160 | "Android >= 4.0", 161 | "iOS >= 8" 162 | ] 163 | } 164 | -------------------------------------------------------------------------------- /template/src/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 24 | 25 | 35 | -------------------------------------------------------------------------------- /template/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cube-ui/cube-template/2386c2c68e1f996b0f463a8abc2827b7a896670e/template/src/assets/logo.png -------------------------------------------------------------------------------- /template/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 42 | 43 | 44 | 60 | -------------------------------------------------------------------------------- /template/src/main.js: -------------------------------------------------------------------------------- 1 | {{#amfeFlexible}} 2 | import 'amfe-flexible' 3 | {{/amfeFlexible}} 4 | {{#if_eq build "standalone"}} 5 | // The Vue build version to load with the `import` command 6 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 7 | {{/if_eq}} 8 | import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 9 | {{#if_eq importType "partly"}} 10 | // By default we import all the components. 11 | // Only reserve the components on demand and remove the rest. 12 | // Style is always required. 13 | import { 14 | {{#lint}} 15 | /* eslint-disable no-unused-vars */ 16 | Style, 17 | {{/lint}} 18 | {{#unless lint}} 19 | Style, 20 | {{/unless}} 21 | // basic 22 | Button, 23 | Loading, 24 | Tip, 25 | Toolbar, 26 | TabBar, 27 | TabPanels, 28 | // form 29 | Checkbox, 30 | CheckboxGroup, 31 | Checker, 32 | Radio, 33 | RadioGroup, 34 | Input, 35 | Textarea, 36 | Select, 37 | Switch, 38 | Rate, 39 | Validator, 40 | Upload, 41 | Form, 42 | // popup 43 | Popup, 44 | Toast, 45 | Picker, 46 | CascadePicker, 47 | DatePicker, 48 | TimePicker, 49 | SegmentPicker, 50 | Dialog, 51 | ActionSheet, 52 | Drawer, 53 | ImagePreview, 54 | // scroll 55 | Scroll, 56 | Slide, 57 | IndexList, 58 | Swipe, 59 | Sticky, 60 | ScrollNav, 61 | ScrollNavBar, 62 | RecycleList{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 63 | } from 'cube-ui'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 64 | {{/if_eq}} 65 | {{#if_eq importType "fully"}} 66 | import Cube from 'cube-ui'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 67 | {{/if_eq}} 68 | import App from './App'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 69 | {{#router}} 70 | import router from './router'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 71 | {{/router}} 72 | 73 | {{#if_eq importType "partly"}} 74 | Vue.use(Button){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 75 | Vue.use(Loading){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 76 | Vue.use(Tip){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 77 | Vue.use(Toolbar){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 78 | Vue.use(TabBar){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 79 | Vue.use(TabPanels){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 80 | Vue.use(Checkbox){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 81 | Vue.use(CheckboxGroup){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 82 | Vue.use(Checker){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 83 | Vue.use(Radio){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 84 | Vue.use(RadioGroup){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 85 | Vue.use(Input){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 86 | Vue.use(Textarea){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 87 | Vue.use(Select){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 88 | Vue.use(Switch){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 89 | Vue.use(Rate){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 90 | Vue.use(Validator){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 91 | Vue.use(Upload){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 92 | Vue.use(Form){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 93 | Vue.use(Popup){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 94 | Vue.use(Toast){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 95 | Vue.use(Picker){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 96 | Vue.use(CascadePicker){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 97 | Vue.use(DatePicker){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 98 | Vue.use(TimePicker){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 99 | Vue.use(SegmentPicker){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 100 | Vue.use(Dialog){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 101 | Vue.use(ActionSheet){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 102 | Vue.use(Drawer){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 103 | Vue.use(ImagePreview){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 104 | Vue.use(Scroll){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 105 | Vue.use(Slide){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 106 | Vue.use(IndexList){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 107 | Vue.use(Swipe){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 108 | Vue.use(Sticky){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 109 | Vue.use(ScrollNav){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 110 | Vue.use(ScrollNavBar){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 111 | Vue.use(RecycleList){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 112 | {{/if_eq}} 113 | {{#if_eq importType "fully"}} 114 | Vue.use(Cube){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 115 | {{/if_eq}} 116 | 117 | Vue.config.productionTip = false{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 118 | 119 | /* eslint-disable no-new */ 120 | new Vue({ 121 | el: '#app', 122 | {{#router}} 123 | router, 124 | {{/router}} 125 | {{#if_eq build "runtime"}} 126 | render: h => h(App){{#if_eq lintConfig "airbnb"}},{{/if_eq}} 127 | {{/if_eq}} 128 | {{#if_eq build "standalone"}} 129 | template: '', 130 | components: { App }{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 131 | {{/if_eq}} 132 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 133 | -------------------------------------------------------------------------------- /template/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 2 | import Router from 'vue-router'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 3 | import HelloWorld from '@/components/HelloWorld'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 4 | 5 | Vue.use(Router){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'HelloWorld', 12 | component: HelloWorld{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 13 | }{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 14 | ]{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 15 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 16 | -------------------------------------------------------------------------------- /template/src/theme.styl: -------------------------------------------------------------------------------- 1 | @require "~cube-ui/src/common/stylus/var/color.styl" 2 | 3 | // action-sheet 4 | $action-sheet-color := $color-grey 5 | $action-sheet-active-color := $color-orange 6 | $action-sheet-bgc := $color-white 7 | $action-sheet-active-bgc := $color-light-grey-opacity 8 | $action-sheet-title-color := $color-dark-grey 9 | $action-sheet-space-bgc := $color-mask-bg 10 | /// picker style 11 | $action-sheet-picker-cancel-color := $color-light-grey 12 | $action-sheet-picker-cancel-active-color := $color-light-grey-s 13 | 14 | // button 15 | $btn-color := $color-white 16 | $btn-bgc := $color-regular-blue 17 | $btn-active-bgc := $color-blue 18 | /// primary 19 | $btn-primary-color := $color-white 20 | $btn-primary-bgc := $color-orange 21 | $btn-primary-active-bgc := $color-dark-orange 22 | /// light 23 | $btn-light-color := $color-grey 24 | $btn-light-bgc := $color-light-grey-sss 25 | $btn-light-active-bgc := $color-active-grey 26 | /// outline 27 | $btn-outline-color := $color-grey 28 | $btn-outline-bgc := transparent 29 | $btn-outline-bdc := $color-grey 30 | $btn-outline-active-bgc := $color-grey-opacity 31 | $btn-outline-active-bdc := $color-grey 32 | /// outline-primary 33 | $btn-outline-primary-color := $color-orange 34 | $btn-outline-primary-bgc := transparent 35 | $btn-outline-primary-bdc := $color-orange 36 | $btn-outline-primary-active-bgc := $color-orange-opacity 37 | $btn-outline-primary-active-bdc := $color-dark-orange 38 | /// disabled 39 | $btn-disabled-color := $color-white 40 | $btn-disabled-bgc := $color-light-grey-s 41 | $btn-disabled-bdc := $color-light-grey-s 42 | 43 | // toolbar 44 | $toolbar-bgc := $color-light-grey-sss 45 | $toolbar-active-bgc := $color-active-grey 46 | 47 | // checkbox 48 | $checkbox-color := $color-grey 49 | $checkbox-icon-color := $color-light-grey-s 50 | /// checked 51 | $checkbox-checked-icon-color := $color-orange 52 | $checkbox-checked-icon-bgc := $color-white 53 | /// disabled 54 | $checkbox-disabled-icon-color := $color-light-grey-ss 55 | $checkbox-disabled-icon-bgc := $color-light-grey-ss 56 | // checkbox hollow 57 | $checkbox-hollow-checked-icon-color := $color-orange 58 | $checkbox-hollow-disabled-icon-color := $color-light-grey-ss 59 | // checkbox-group 60 | $checkbox-group-bgc := $color-white 61 | $checkbox-group-horizontal-bdc := $color-light-grey-s 62 | 63 | // radio 64 | $radio-group-bgc := $color-white 65 | $radio-group-horizontal-bdc := $color-light-grey-s 66 | $radio-color := $color-grey 67 | $radio-icon-color := $color-light-grey-s 68 | /// selected 69 | $radio-selected-icon-color := $color-white 70 | $radio-selected-icon-bgc := $color-orange 71 | /// disabled 72 | $radio-disabled-icon-bgc := $color-light-grey-ss 73 | // radio hollow 74 | $radio-hollow-selected-icon-color := $color-orange 75 | $radio-hollow-disabled-icon-color := $color-light-grey-ss 76 | 77 | //checker 78 | $checker-item-color := $color-grey 79 | $checker-item-bdc := $color-light-grey-sss 80 | $checker-item-bgc := $color-white 81 | $checker-item-active-color := $color-orange 82 | $checker-item-active-bdc := $color-orange 83 | $checker-item-active-bgc := $color-light-orange-opacity 84 | 85 | // dialog 86 | $dialog-color := $color-grey 87 | $dialog-bgc := $color-white 88 | $dialog-icon-color := $color-regular-blue 89 | $dialog-icon-bgc := $color-background 90 | $dialog-title-color := $color-dark-grey 91 | $dialog-close-color := $color-light-grey 92 | $dialog-btn-color := $color-light-grey 93 | $dialog-btn-bgc := $color-white 94 | $dialog-btn-active-bgc := $color-light-grey-opacity 95 | $dialog-btn-highlight-color := $color-orange 96 | $dialog-btn-highlight-active-bgc := $color-light-orange-opacity 97 | $dialog-btn-disabled-color := $color-light-grey 98 | $dialog-btn-disabled-active-bgc := transparent 99 | $dialog-btns-split-color := $color-row-line 100 | 101 | // index-list 102 | $index-list-bgc := $color-white 103 | $index-list-title-color := $color-dark-grey 104 | $index-list-anchor-color := $color-light-grey 105 | $index-list-anchor-bgc := #f7f7f7 106 | $index-list-item-color := $color-dark-grey 107 | $index-list-item-active-bgc := $color-light-grey-opacity 108 | $index-list-nav-color := $color-grey 109 | $index-list-nav-active-color := $color-orange 110 | 111 | // picker 112 | $picker-bgc := $color-white 113 | $picker-title-color := $color-dark-grey 114 | $picker-subtitle-color := $color-light-grey 115 | $picker-confirm-btn-color := $color-orange 116 | $picker-confirm-btn-active-color := $color-light-orange 117 | $picker-cancel-btn-color := $color-light-grey 118 | $picker-cancel-btn-active-color := $color-light-grey-s 119 | $picker-item-color := $color-dark-grey 120 | 121 | // popup 122 | $popup-mask-bgc := rgb(37, 38, 45) 123 | $popup-mask-opacity := .4 124 | 125 | // slide 126 | $slide-dot-bgc := $color-light-grey-s 127 | $slide-dot-active-bgc := $color-orange 128 | 129 | // time-picker 130 | 131 | // tip 132 | $tip-color := $color-white 133 | $tip-bgc := $color-dark-grey-opacity 134 | 135 | // toast 136 | $toast-color := $color-light-grey-s 137 | $toast-bgc := rgba(37, 38, 45, 0.9) 138 | 139 | // upload 140 | $upload-btn-color := $color-grey 141 | $upload-btn-bgc := $color-white 142 | $upload-btn-active-bgc := $color-light-grey-opacity 143 | $upload-btn-box-shadow := 0 0 6px 2px $color-grey-opacity 144 | $upload-btn-border-color := #e5e5e5 145 | $upload-file-bgc := $color-white 146 | $upload-file-remove-color := rgba(0, 0, 0, .8) 147 | $upload-file-remove-bgc := $color-white 148 | $upload-file-state-bgc := $color-mask-bg 149 | $upload-file-success-color := $color-orange 150 | $upload-file-error-color := #f43530 151 | $upload-file-status-bgc := $color-white 152 | $upload-file-progress-color := $color-white 153 | 154 | // switch 155 | $switch-on-bgc := $color-orange 156 | $switch-off-bgc := $color-white 157 | $switch-off-border-color := #e4e4e4 158 | 159 | // input 160 | $input-color := $color-grey 161 | $input-bgc := $color-white 162 | $input-border-color := $color-row-line 163 | $input-focus-border-color := $color-orange 164 | $input-placeholder-color := $color-light-grey-s 165 | $input-clear-icon-color := $color-light-grey 166 | 167 | //textarea 168 | $textarea-color := $color-grey 169 | $textarea-bgc := $color-white 170 | $textarea-border-color := $color-row-line 171 | $textarea-focus-border-color := $color-orange 172 | $textarea-outline-color := $color-orange 173 | $textarea-placeholder-color := $color-light-grey-s 174 | $textarea-indicator-color := $color-light-grey-s 175 | 176 | // validator 177 | $validator-msg-def-color := #e64340 178 | 179 | // select 180 | $select-color := $color-grey 181 | $select-bgc := $color-white 182 | $select-disabled-color := #b8b8b8 183 | $select-disabled-bgc := $color-light-grey-opacity 184 | $select-border-color := $color-light-grey-s 185 | $select-border-active-color := $color-orange 186 | $select-icon-color := $color-light-grey 187 | $select-placeholder-color := $color-light-grey-s 188 | 189 | // swipe 190 | $swipe-btn-color := $color-white 191 | 192 | // form 193 | $form-color := $color-grey 194 | $form-bgc := $color-white 195 | $form-invalid-color := #e64340 196 | $form-group-legend-color := $color-light-grey 197 | $form-group-legend-bgc := $color-background 198 | $form-label-required-color := #e64340 199 | 200 | // drawer 201 | $drawer-color := $color-dark-grey 202 | $drawer-title-bdc := $color-light-grey-ss 203 | $drawer-title-bgc := $color-white 204 | $drawer-panel-bgc := $color-white 205 | $drawer-item-active-bgc := $color-light-grey-opacity 206 | 207 | // scroll-nav 208 | $scroll-nav-bgc := $color-white 209 | $scroll-nav-color := $color-grey 210 | $scroll-nav-active-color := $color-orange 211 | 212 | // image-preview 213 | $image-preview-counter-color := $color-white 214 | 215 | // tab-bar & tab-panel 216 | $tab-color := $color-grey 217 | $tab-active-color := $color-dark-orange 218 | $tab-slider-bgc := $color-dark-orange 219 | -------------------------------------------------------------------------------- /template/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cube-ui/cube-template/2386c2c68e1f996b0f463a8abc2827b7a896670e/template/static/.gitkeep -------------------------------------------------------------------------------- /template/test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // the name of the method is the filename. 3 | // can be used in tests like this: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // for how to write custom assertions see 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | exports.assertion = function (selector, count) { 10 | this.message = 'Testing if element <' + selector + '> has count: ' + count{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 11 | this.expected = count{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 12 | this.pass = function (val) { 13 | return val === this.expected{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 14 | } 15 | this.value = function (res) { 16 | return res.value{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 17 | } 18 | this.command = function (cb) { 19 | var self = this{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 20 | return this.api.execute(function (selector) { 21 | return document.querySelectorAll(selector).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 22 | }, [selector], function (res) { 23 | cb.call(self, res){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 24 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /template/test/e2e/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | require('babel-register') 2 | var config = require('../../config') 3 | 4 | // http://nightwatchjs.org/gettingstarted#settings-file 5 | module.exports = { 6 | src_folders: ['test/e2e/specs'], 7 | output_folder: 'test/e2e/reports', 8 | custom_assertions_path: ['test/e2e/custom-assertions'], 9 | 10 | selenium: { 11 | start_process: true, 12 | server_path: require('selenium-server').path, 13 | host: '127.0.0.1', 14 | port: 4444, 15 | cli_args: { 16 | 'webdriver.chrome.driver': require('chromedriver').path 17 | } 18 | }, 19 | 20 | test_settings: { 21 | default: { 22 | selenium_port: 4444, 23 | selenium_host: 'localhost', 24 | silent: true, 25 | globals: { 26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port) 27 | } 28 | }, 29 | 30 | chrome: { 31 | desiredCapabilities: { 32 | browserName: 'chrome', 33 | javascriptEnabled: true, 34 | acceptSslCerts: true 35 | } 36 | }, 37 | 38 | firefox: { 39 | desiredCapabilities: { 40 | browserName: 'firefox', 41 | javascriptEnabled: true, 42 | acceptSslCerts: true 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /template/test/e2e/runner.js: -------------------------------------------------------------------------------- 1 | // 1. start the dev server using production config 2 | process.env.NODE_ENV = 'testing'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 3 | 4 | const webpack = require('webpack'){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 5 | const DevServer = require('webpack-dev-server'){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 6 | 7 | const webpackConfig = require('../../build/webpack.prod.conf'){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 8 | const devConfigPromise = require('../../build/webpack.dev.conf'){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 9 | 10 | let server{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 11 | 12 | devConfigPromise.then(devConfig => { 13 | const devServerOptions = devConfig.devServer{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 14 | const compiler = webpack(webpackConfig){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 15 | server = new DevServer(compiler, devServerOptions){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 16 | const port = devServerOptions.port{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 17 | const host = devServerOptions.host{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 18 | return server.listen(port, host){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 19 | }) 20 | .then(() => { 21 | // 2. run the nightwatch test suite against it 22 | // to run in additional browsers: 23 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings" 24 | // 2. add it to the --env flag below 25 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox` 26 | // For more information on Nightwatch's config file, see 27 | // http://nightwatchjs.org/guide#settings-file 28 | let opts = process.argv.slice(2){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 29 | if (opts.indexOf('--config') === -1) { 30 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 31 | } 32 | if (opts.indexOf('--env') === -1) { 33 | opts = opts.concat(['--env', 'chrome']){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 34 | } 35 | 36 | const spawn = require('cross-spawn'){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 37 | const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 38 | 39 | runner.on('exit', function (code) { 40 | server.close(){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 41 | process.exit(code){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 42 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 43 | 44 | runner.on('error', function (err) { 45 | server.close(){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 46 | throw err{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 47 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 48 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 49 | -------------------------------------------------------------------------------- /template/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function {{#if_eq lintConfig "airbnb"}}test{{/if_eq}}(browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end(){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 18 | }{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 19 | }{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 20 | -------------------------------------------------------------------------------- /template/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { {{#if_eq runner "karma"}} 3 | "mocha": true{{/if_eq}}{{#if_eq runner "jest"}} 4 | "jest": true{{/if_eq}} 5 | }, 6 | "globals": { {{#if_eq runner "karma"}} 7 | "expect": true, 8 | "sinon": true{{/if_eq}} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /template/test/unit/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 2 | 3 | Vue.config.productionTip = false{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 4 | 5 | // require all test files (files that ends with .spec.js) 6 | const testsContext = require.context('./specs', true, /\.spec$/){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 7 | testsContext.keys().forEach(testsContext){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 8 | 9 | // require all src files except main.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 13 | srcContext.keys().forEach(srcContext){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 14 | -------------------------------------------------------------------------------- /template/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | },{{#e2e}} 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ],{{/e2e}} 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | {{#router}} 28 | '!src/router/index.js', 29 | {{/router}} 30 | '!**/node_modules/**' 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /template/test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | // This is a karma config file. For more details see 2 | // http://karma-runner.github.io/0.13/config/configuration-file.html 3 | // we are also using it with karma-webpack 4 | // https://github.com/webpack/karma-webpack 5 | 6 | var webpackConfig = require('../../build/webpack.test.conf'){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | // to run in additional browsers: 11 | // 1. install corresponding karma launcher 12 | // http://karma-runner.github.io/0.13/config/browsers.html 13 | // 2. add it to the `browsers` array below. 14 | browsers: ['PhantomJS'], 15 | frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'], 16 | reporters: ['spec', 'coverage'], 17 | files: ['./index.js'], 18 | preprocessors: { 19 | './index.js': ['webpack', 'sourcemap'] 20 | }, 21 | webpack: webpackConfig, 22 | webpackMiddleware: { 23 | noInfo: true{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 24 | }, 25 | coverageReporter: { 26 | dir: './coverage', 27 | reporters: [ 28 | { type: 'lcov', subdir: '.' }, 29 | { type: 'text-summary' }{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 30 | ] 31 | }{{#if_eq lintConfig "airbnb"}},{{/if_eq}} 32 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 33 | }{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 34 | -------------------------------------------------------------------------------- /template/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /template/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 2 | import Cube from 'cube-ui'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 3 | Vue.use(Cube){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 4 | import HelloWorld from '@/components/HelloWorld'{{#if_eq lintConfig "airbnb"}};{{/if_eq}} 5 | 6 | describe('HelloWorld.vue', () => { 7 | it('should render correct contents', () => { 8 | const Constructor = Vue.extend(HelloWorld){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 9 | const vm = new Constructor().$mount(){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 10 | expect(vm.$el.querySelector('.hello h1').textContent) 11 | {{#if_eq runner "karma"}}.to.equal('Welcome to Your Vue.js App'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}{{/if_eq}}{{#if_eq runner "jest"}}.toEqual('Welcome to Your Vue.js App'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}{{/if_eq}} 12 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 13 | }){{#if_eq lintConfig "airbnb"}};{{/if_eq}} 14 | --------------------------------------------------------------------------------