From 2f670c5ef738471d1cbccbeaf9d8b1f9f3fd56f3 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 16:56:00 +0800 Subject: [PATCH 01/14] feat: improve vue-class-component example --- .../vue-class-component/components/Base.vue | 40 +++++++++++++++++++ .../vue-class-component/components/Child.vue | 23 +++++++++++ examples/vue-class-component/pages/about.vue | 5 ++- examples/vue-class-component/pages/index.vue | 33 +++------------ 4 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 examples/vue-class-component/components/Base.vue create mode 100644 examples/vue-class-component/components/Child.vue diff --git a/examples/vue-class-component/components/Base.vue b/examples/vue-class-component/components/Base.vue new file mode 100644 index 0000000000..e2790a4ec2 --- /dev/null +++ b/examples/vue-class-component/components/Base.vue @@ -0,0 +1,40 @@ + + + diff --git a/examples/vue-class-component/components/Child.vue b/examples/vue-class-component/components/Child.vue new file mode 100644 index 0000000000..b3c5155dc0 --- /dev/null +++ b/examples/vue-class-component/components/Child.vue @@ -0,0 +1,23 @@ + + + diff --git a/examples/vue-class-component/pages/about.vue b/examples/vue-class-component/pages/about.vue index 484c798b82..cbe04d7fda 100644 --- a/examples/vue-class-component/pages/about.vue +++ b/examples/vue-class-component/pages/about.vue @@ -1,3 +1,6 @@ diff --git a/examples/vue-class-component/pages/index.vue b/examples/vue-class-component/pages/index.vue index ce87828622..ff468d2ed9 100644 --- a/examples/vue-class-component/pages/index.vue +++ b/examples/vue-class-component/pages/index.vue @@ -1,41 +1,18 @@ From dca0bd9a70243144842a6bda64679c118743a2bd Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 16:57:08 +0800 Subject: [PATCH 02/14] fix: error alias in vue-class-component example --- examples/vue-class-component/nuxt.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vue-class-component/nuxt.config.js b/examples/vue-class-component/nuxt.config.js index a61292b4ae..4e7a3097a9 100644 --- a/examples/vue-class-component/nuxt.config.js +++ b/examples/vue-class-component/nuxt.config.js @@ -4,7 +4,7 @@ module.exports = { plugins: ['transform-decorators-legacy', 'transform-class-properties'] }, extend (config) { - config.resolve.alias['nuxt-class-component'] = '~plugins/nuxt-class-component' + config.resolve.alias['nuxt-class-component'] = '@/plugins/nuxt-class-component' } } } From 37c23c33d237e4d953f050afe0bcfaf0836c3046 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sat, 21 Oct 2017 21:05:07 +0800 Subject: [PATCH 03/14] feat: update nuxt to latest in apollo example --- examples/vue-apollo/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vue-apollo/package.json b/examples/vue-apollo/package.json index f26ec4014c..c9ffee9f88 100644 --- a/examples/vue-apollo/package.json +++ b/examples/vue-apollo/package.json @@ -2,7 +2,7 @@ "name": "nuxt-vue-apollo", "dependencies": { "@nuxtjs/apollo": "^2.1.1", - "nuxt": "^1.0.0-rc9" + "nuxt": "latest" }, "scripts": { "dev": "nuxt", From 671b8d0759d602398d196abf5fbaef651e7cfd87 Mon Sep 17 00:00:00 2001 From: Paul Gascou-Vaillancourt Date: Sat, 21 Oct 2017 12:32:44 -0400 Subject: [PATCH 04/14] Fix CONTRIBUTING.md link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75f5826a6b..4a75680844 100644 --- a/README.md +++ b/README.md @@ -254,4 +254,4 @@ Note: we recommend putting `.nuxt` in `.npmignore` or `.gitignore`. https://github.com/nuxt/nuxt.js/projects/1 ## Contributing -Please see our [contributing.md](./contributing.md) \ No newline at end of file +Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) From 386096a21e9d6d0c37830059aca49eeec24a949a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 22 Oct 2017 12:43:05 +0800 Subject: [PATCH 05/14] feat: update nuxt to latest in typescript example --- examples/typescript/package.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/typescript/package.json b/examples/typescript/package.json index 17973f83f6..5e795aa8a0 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -4,12 +4,15 @@ "dependencies": { "axios": "^0.16.1", "gsap": "^1.19.1", - "nuxt": "^1.0.0-alpha2", - "nuxt-class-component": "^1.0.1", + "nuxt": "latest", + "nuxt-class-component": "^1.0.3", "tachyons": "^4.7.0", - "vue-class-component": "^5.0.1", - "vue-property-decorator": "^5.0.1", - "vuex-class": "^0.2.0" + "vue": "~2.5.1", + "vue-server-renderer": "~2.5.1", + "vue-template-compiler": "~2.5.1", + "vue-class-component": "^6.0.0", + "vue-property-decorator": "^6.0.0", + "vuex-class": "^0.3.0" }, "scripts": { "dev": "nuxt", @@ -18,7 +21,7 @@ "generate": "nuxt generate" }, "devDependencies": { - "ts-loader": "^2.0.3", + "ts-loader": "^3.0.0", "typescript": "^2.2.2" } } From c0a6ed9ea3eea7e2ee8563502041a3054d199180 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 22 Oct 2017 12:44:33 +0800 Subject: [PATCH 06/14] fix: error alias in typescript example --- examples/typescript/nuxt.config.js | 2 +- examples/typescript/pages/index.vue | 4 +- examples/typescript/store/index.ts | 66 ++++++++++++++--------------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/examples/typescript/nuxt.config.js b/examples/typescript/nuxt.config.js index e6c3bdf87d..cc6493b7ed 100644 --- a/examples/typescript/nuxt.config.js +++ b/examples/typescript/nuxt.config.js @@ -22,5 +22,5 @@ module.exports = { build: { vendor: ['axios', 'gsap', 'vuex-class', 'nuxt-class-component'] }, - modules: ['~modules/typescript'] + modules: ['~/modules/typescript'] } diff --git a/examples/typescript/pages/index.vue b/examples/typescript/pages/index.vue index f92713be3c..a241284c62 100644 --- a/examples/typescript/pages/index.vue +++ b/examples/typescript/pages/index.vue @@ -16,7 +16,7 @@ \ No newline at end of file + diff --git a/examples/typescript/store/index.ts b/examples/typescript/store/index.ts index 292c381318..bfffcd5175 100644 --- a/examples/typescript/store/index.ts +++ b/examples/typescript/store/index.ts @@ -1,33 +1,33 @@ -import axios from "~plugins/axios"; - -export const state = () => ({ - selected: 1, - people: [] -}); - -export const mutations = { - select(state, id) { - state.selected = id; - }, - setPeople(state, people) { - state.people = people; - } -}; - -export const getters = { - selectedPerson: state => { - const p = state.people.find(person => person.id === state.selected); - return p ? p : { first_name: "Please,", last_name: "select someone" }; - } -}; - -export const actions = { - async nuxtServerInit({ commit }) { - const response = await axios.get("/random-data.json"); - const people = response.data.slice(0, 10); - commit("setPeople", people); - }, - select({ commit }, id) { - commit("select", id); - } -}; +import axios from "~/plugins/axios"; + +export const state = () => ({ + selected: 1, + people: [] +}); + +export const mutations = { + select(state, id) { + state.selected = id; + }, + setPeople(state, people) { + state.people = people; + } +}; + +export const getters = { + selectedPerson: state => { + const p = state.people.find(person => person.id === state.selected); + return p ? p : { first_name: "Please,", last_name: "select someone" }; + } +}; + +export const actions = { + async nuxtServerInit({ commit }) { + const response = await axios.get("/random-data.json"); + const people = response.data.slice(0, 10); + commit("setPeople", people); + }, + select({ commit }, id) { + commit("select", id); + } +}; From 05d0b7a3cdfb90446024189c49fba84f2ec9b562 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 22 Oct 2017 12:46:19 +0800 Subject: [PATCH 07/14] fix: adjust ts config to fix startup error --- examples/typescript/modules/typescript.js | 30 ++++++++---- examples/typescript/tsconfig.json | 58 +++++++++++------------ 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/examples/typescript/modules/typescript.js b/examples/typescript/modules/typescript.js index a45d341b89..2bad37f199 100644 --- a/examples/typescript/modules/typescript.js +++ b/examples/typescript/modules/typescript.js @@ -1,16 +1,26 @@ -module.exports = function (options) { +module.exports = function(options) { // Extend build - this.extendBuild((config) => { + this.extendBuild(config => { + const tsLoader = { + loader: "ts-loader", + options: { + appendTsSuffixTo: [/\.vue$/] + } + }; // Add TypeScript loader - config.module.rules.push({ - test: /\.ts$/, - loader: 'ts-loader' - }) + config.module.rules.push( + Object.assign( + { + test: /((client|server)\.js)|(\.tsx?)$/ + }, + tsLoader + ) + ); // Add TypeScript loader for vue files for (let rule of config.module.rules) { - if (rule.loader === 'vue-loader') { - rule.query.loaders.ts = 'ts-loader?{"appendTsSuffixTo":["\\\\.vue$"]}' + if (rule.loader === "vue-loader") { + rule.options.loaders.ts = tsLoader; } } - }) -} + }); +}; diff --git a/examples/typescript/tsconfig.json b/examples/typescript/tsconfig.json index 3a40a830cd..557fd275fa 100644 --- a/examples/typescript/tsconfig.json +++ b/examples/typescript/tsconfig.json @@ -1,29 +1,29 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": [ - "dom", - "es2015" - ], - "module": "es2015", - "moduleResolution": "node", - "experimentalDecorators": true, - "declaration": true, - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true, - "removeComments": true, - "suppressImplicitAnyIndexErrors": true, - "allowSyntheticDefaultImports": true, - "baseUrl": ".", - "paths": { - "~": ["./"], - "~assets/*": ["./assets/*"], - "~components/*": ["./components/*"], - "~middleware/*": ["./middleware/*"], - "~pages/*": ["./pages/*"], - "~plugins/*": ["./plugins/*"], - "~static/*": ["./static/*"] - } - } -} +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "es2015" + ], + "module": "es2015", + "moduleResolution": "node", + "experimentalDecorators": true, + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true, + "removeComments": true, + "suppressImplicitAnyIndexErrors": true, + "allowSyntheticDefaultImports": true, + "baseUrl": ".", + "allowJs": true, + "paths": { + "~/": ["./"], + "~/assets/*": ["./assets/*"], + "~/components/*": ["./components/*"], + "~/middleware/*": ["./middleware/*"], + "~/pages/*": ["./pages/*"], + "~/plugins/*": ["./plugins/*"], + "~/static/*": ["./static/*"] + } + } +} From 407569480b7ef5fa016a919f4185a0a851bf0b43 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 23 Oct 2017 17:27:30 +0800 Subject: [PATCH 08/14] refactor: use nuxt-class-component in example --- examples/vue-class-component/nuxt.config.js | 3 --- examples/vue-class-component/package.json | 3 ++- .../plugins/nuxt-class-component.js | 14 -------------- 3 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 examples/vue-class-component/plugins/nuxt-class-component.js diff --git a/examples/vue-class-component/nuxt.config.js b/examples/vue-class-component/nuxt.config.js index 4e7a3097a9..4d32a9ca0a 100644 --- a/examples/vue-class-component/nuxt.config.js +++ b/examples/vue-class-component/nuxt.config.js @@ -2,9 +2,6 @@ module.exports = { build: { babel: { plugins: ['transform-decorators-legacy', 'transform-class-properties'] - }, - extend (config) { - config.resolve.alias['nuxt-class-component'] = '@/plugins/nuxt-class-component' } } } diff --git a/examples/vue-class-component/package.json b/examples/vue-class-component/package.json index e672615065..89e9d65c2a 100644 --- a/examples/vue-class-component/package.json +++ b/examples/vue-class-component/package.json @@ -4,7 +4,8 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "nuxt": "latest", - "vue-class-component": "^5.0.1" + "nuxt-class-component": "^1.0.3", + "vue": "~2.4.2" }, "scripts": { "dev": "nuxt", diff --git a/examples/vue-class-component/plugins/nuxt-class-component.js b/examples/vue-class-component/plugins/nuxt-class-component.js deleted file mode 100644 index 2f5188d00b..0000000000 --- a/examples/vue-class-component/plugins/nuxt-class-component.js +++ /dev/null @@ -1,14 +0,0 @@ -import Component from 'vue-class-component' - -Component.registerHooks([ - 'beforeRouteEnter', - 'beforeRouteLeave', - 'asyncData', - 'fetch', - 'middleware', - 'layout', - 'transition', - 'scrollToTop' -]) - -export default Component From 72529c69da186f821be1d38d6e22866ba3d4f6f9 Mon Sep 17 00:00:00 2001 From: pimlie Date: Mon, 23 Oct 2017 23:43:59 +0200 Subject: [PATCH 09/14] dont assume /index.html exists --- lib/builder/generator.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 950ee46b52..71a8986d55 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -73,11 +73,14 @@ export default class Generator extends Tapable { })) } - // Copy /index.html to /200.html for surge SPA - // https://surge.sh/help/adding-a-200-page-for-client-side-routing - const _200Path = join(this.distPath, '200.html') - if (!existsSync(_200Path)) { - await copy(join(this.distPath, 'index.html'), _200Path) + const indexPath = join(this.distPath, 'index.html') + if (existsSync(indexPath) { + // Copy /index.html to /200.html for surge SPA + // https://surge.sh/help/adding-a-200-page-for-client-side-routing + const _200Path = join(this.distPath, '200.html') + if (!existsSync(_200Path)) { + await copy(indexPath, _200Path) + } } const duration = Math.round((Date.now() - s) / 100) / 10 From 1cb1238d8a83dfbe24e156862e80594a75cf824a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 25 Oct 2017 10:07:29 +0800 Subject: [PATCH 10/14] refactor: remove vue dependency after nuxt-class-component upgrade --- examples/vue-class-component/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/vue-class-component/package.json b/examples/vue-class-component/package.json index 89e9d65c2a..f4953a0a84 100644 --- a/examples/vue-class-component/package.json +++ b/examples/vue-class-component/package.json @@ -4,8 +4,7 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "nuxt": "latest", - "nuxt-class-component": "^1.0.3", - "vue": "~2.4.2" + "nuxt-class-component": "^1.0.3" }, "scripts": { "dev": "nuxt", From f5acb6fc0ee81f501745f8393305fd38c4097048 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 25 Oct 2017 19:27:51 +0800 Subject: [PATCH 11/14] fix: syntax error in generator.js --- lib/builder/generator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 71a8986d55..3afd1cb79a 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -74,7 +74,7 @@ export default class Generator extends Tapable { } const indexPath = join(this.distPath, 'index.html') - if (existsSync(indexPath) { + if (existsSync(indexPath)) { // Copy /index.html to /200.html for surge SPA // https://surge.sh/help/adding-a-200-page-for-client-side-routing const _200Path = join(this.distPath, '200.html') From 5d3156c0c7da70915d6a1600879077f41ea013af Mon Sep 17 00:00:00 2001 From: John Fischer Date: Sat, 14 Oct 2017 19:33:26 +0200 Subject: [PATCH 12/14] Catch cryptic error when a plugin is not found --- lib/builder/builder.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index c85c5c7b5c..4010101abe 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -5,7 +5,7 @@ import hash from 'hash-sum' import pify from 'pify' import webpack from 'webpack' import serialize from 'serialize-javascript' -import { join, resolve, basename, dirname } from 'path' +import { join, resolve, basename, extname, dirname } from 'path' import Tapable from 'tappable' import MFS from 'memory-fs' import webpackDevMiddleware from 'webpack-dev-middleware' @@ -62,8 +62,11 @@ export default class Builder extends Tapable { get plugins () { return this.options.plugins.map((p, i) => { if (typeof p === 'string') p = { src: p } - p.src = this.nuxt.resolvePath(p.src) - return { src: p.src, ssr: (p.ssr !== false), name: `plugin${i}` } + return { + src: this.nuxt.resolvePath(p.src), + ssr: (p.ssr !== false), + name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + } }) } From 08e770c1e00c30d1115a2698b0a20d243d09710a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 27 Oct 2017 22:15:34 +0800 Subject: [PATCH 13/14] refactor: upgrade nuxt-class-component to a stabe version --- examples/vue-class-component/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vue-class-component/package.json b/examples/vue-class-component/package.json index f4953a0a84..797a48f36e 100644 --- a/examples/vue-class-component/package.json +++ b/examples/vue-class-component/package.json @@ -4,7 +4,7 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "nuxt": "latest", - "nuxt-class-component": "^1.0.3" + "nuxt-class-component": "^1.0.4" }, "scripts": { "dev": "nuxt", From f2663033fcc275fff592944ba54a7b7b36b7a21d Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 27 Oct 2017 18:45:34 +0330 Subject: [PATCH 14/14] feat(nuxt-generate): --no-build flag Much faster generates for when just dynamic routes changed --- bin/nuxt-generate | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/nuxt-generate b/bin/nuxt-generate index f86cd43eba..d0313caa19 100755 --- a/bin/nuxt-generate +++ b/bin/nuxt-generate @@ -17,10 +17,11 @@ const argv = parseArgs(process.argv.slice(2), { s: 'spa', u: 'universal' }, - boolean: ['h', 's', 'u'], + boolean: ['h', 's', 'u', 'build'], string: ['c'], default: { - c: 'nuxt.config.js' + c: 'nuxt.config.js', + build: true } }) @@ -36,6 +37,7 @@ if (argv.help) { --universal Launch in Universal mode (default) --config-file, -c Path to Nuxt.js config file (default: nuxt.config.js) --help, -h Displays this message + --no-build Just run generate for faster builds when just dynamic routes changed. Nuxt build is needed before this command. `) process.exit(0) } @@ -62,7 +64,13 @@ debug('Generating...') const nuxt = new Nuxt(options) const builder = new Builder(nuxt) const generator = new Generator(nuxt, builder) -generator.generate() + +const generateOptions = { + init: true, + build: argv['build'] +} + +generator.generate(generateOptions) .then(() => { debug('Generate done') process.exit(0)