diff --git a/meta.js b/meta.js index 0dc63e651b..13bd7bd54e 100644 --- a/meta.js +++ b/meta.js @@ -23,7 +23,6 @@ module.exports = { return templateVersion }, }, - prompts: { name: { type: 'string', @@ -61,6 +60,26 @@ module.exports = { type: 'confirm', message: 'Install vue-router?', }, + deploy: { + type: 'confirm', + message: 'Setup a deploy command for GitHub pages?', + }, + deployBuild: { + when: 'deploy', + type: 'confirm', + message: 'Build project when deploying?', + }, + branch: { + when: 'deploy', + default: 'gh-pages', + type: 'string', + message: 'What branch should the built site be deployed to?', + }, + baseUrl: { + when: 'deploy', + type: 'string', + message: 'What is the GitHub project? (Leave blank for User & Organization pages)', + }, lint: { type: 'confirm', message: 'Use ESLint to lint your code?', diff --git a/template/config/index.js b/template/config/index.js index d1ec13d12a..9493f9cb16 100644 --- a/template/config/index.js +++ b/template/config/index.js @@ -51,8 +51,11 @@ module.exports = { // Paths assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', + {{#deploy}} + assetsPublicPath: '/{{ baseUrl }}/', + {{else}} assetsPublicPath: '/', - + {{/deploy}} /** * Source Maps */ diff --git a/template/package.json b/template/package.json index db5f9564d2..4f5900a3bd 100644 --- a/template/package.json +++ b/template/package.json @@ -22,6 +22,9 @@ {{#lint}} "lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}", {{/lint}} + {{#deploy}} + "deploy": "{{#deployBuild}}npm run build;{{/deployBuild}}push-dir --dir=dist --branch={{ branch }} --cleanup", + {{/deploy}} "build": "node build/build.js" }, "dependencies": { @@ -103,6 +106,9 @@ "postcss-import": "^11.0.0", "postcss-loader": "^2.0.8", "postcss-url": "^7.2.1", + {{#deploy}} + "push-dir": "^0.4.1", + {{/deploy}} "semver": "^5.3.0", "shelljs": "^0.7.6", "optimize-css-assets-webpack-plugin": "^3.2.0",