From fd7184eec87f7f41e50be7a9eac7ed8b743c0749 Mon Sep 17 00:00:00 2001 From: Andrew Boyd Date: Mon, 21 Dec 2020 20:29:02 -0500 Subject: [PATCH 1/3] adds nuxt module to source files and build process --- dist/nuxt/index.js | 1 + dist/nuxt/plugin.js | 5 ++ nuxt/index.js | 10 +++ nuxt/plugin.js | 4 + package-lock.json | 193 +++++++++++++++++++++++--------------------- package.json | 4 +- 6 files changed, 126 insertions(+), 91 deletions(-) create mode 100644 dist/nuxt/index.js create mode 100644 dist/nuxt/plugin.js create mode 100644 nuxt/index.js create mode 100644 nuxt/plugin.js diff --git a/dist/nuxt/index.js b/dist/nuxt/index.js new file mode 100644 index 0000000..64363f1 --- /dev/null +++ b/dist/nuxt/index.js @@ -0,0 +1 @@ +import path from"path";export default function nuxtVueFormulate(t){const o=Object.assign({},this.options.formulate,t);this.addPlugin({src:path.resolve(__dirname,"plugin.js"),options:o})}; \ No newline at end of file diff --git a/dist/nuxt/plugin.js b/dist/nuxt/plugin.js new file mode 100644 index 0000000..3772832 --- /dev/null +++ b/dist/nuxt/plugin.js @@ -0,0 +1,5 @@ +/* eslint-disable */ +import Vue from 'vue' +import VueFormulate from '@braid/vue-formulate' + +Vue.use(VueFormulate, <%= serialize(options) %>) diff --git a/nuxt/index.js b/nuxt/index.js new file mode 100644 index 0000000..2a943f3 --- /dev/null +++ b/nuxt/index.js @@ -0,0 +1,10 @@ +import path from 'path' + +export default function nuxtVueFormulate (moduleOptions) { + const formulateOptions = Object.assign({}, this.options.formulate, moduleOptions) + // Register `plugin.js` template + this.addPlugin({ + src: path.resolve(__dirname, 'plugin.js'), + options: formulateOptions + }) +} diff --git a/nuxt/plugin.js b/nuxt/plugin.js new file mode 100644 index 0000000..7be3f6a --- /dev/null +++ b/nuxt/plugin.js @@ -0,0 +1,4 @@ +import Vue from 'vue' +import VueFormulate from '@braid/vue-formulate' + +Vue.use(VueFormulate, <%= serialize(options) %>) diff --git a/package-lock.json b/package-lock.json index e4daff3..49c96d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3843,16 +3843,6 @@ "integrity": "sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q==", "dev": true }, - "@types/mini-css-extract-plugin": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@types/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.1.tgz", - "integrity": "sha512-+mN04Oszdz9tGjUP/c1ReVwJXxSniLd7lF++sv+8dkABxVNthg6uccei+4ssKxRHGoMmPxdn7uBdJWONSJGTGQ==", - "dev": true, - "optional": true, - "requires": { - "@types/webpack": "*" - } - }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -4320,6 +4310,16 @@ "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "browserslist": { "version": "4.14.3", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.3.tgz", @@ -4364,6 +4364,34 @@ "integrity": "sha512-s3XAUFaC/ntDb1O3lcw9K8MPeOW7KO3z9+GzAoBxfz1B0VdacXPMKgFUtG4KIsgmnbexmi013s9miVu4h+qMHw==", "dev": true }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "optional": true + }, "electron-to-chromium": { "version": "1.3.570", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.570.tgz", @@ -4391,6 +4419,25 @@ "path-exists": "^4.0.0" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -4476,6 +4523,16 @@ "minipass": "^3.1.1" } }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + }, "terser-webpack-plugin": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz", @@ -4492,6 +4549,18 @@ "terser": "^4.6.12", "webpack-sources": "^1.4.3" } + }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.1.2", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz", + "integrity": "sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q==", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + } } } }, @@ -19275,6 +19344,30 @@ "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", "dev": true }, + "uglify-es": { + "version": "3.3.9", + "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", + "integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==", + "dev": true, + "requires": { + "commander": "~2.13.0", + "source-map": "~0.6.1" + }, + "dependencies": { + "commander": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "uglify-js": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", @@ -19715,86 +19808,6 @@ } } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.0.0-beta.7", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.7.tgz", - "integrity": "sha512-xQ8/GZmRPdQ3EinnE0IXwdVoDzh7Dowo0MowoyBuScEBXrRabw6At5/IdtD3waKklKW5PGokPsm8KRN6rvQ1cw==", - "dev": true, - "optional": true, - "requires": { - "@types/mini-css-extract-plugin": "^0.9.1", - "chalk": "^3.0.0", - "hash-sum": "^2.0.0", - "loader-utils": "^1.2.3", - "merge-source-map": "^1.1.0", - "source-map": "^0.6.1" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "optional": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "optional": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "optional": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "vue-property-decorator": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/vue-property-decorator/-/vue-property-decorator-8.3.0.tgz", diff --git a/package.json b/package.json index eaf1de6..c067c20 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,12 @@ "./sfc": "src/Formulate.js" }, "scripts": { - "build": "npm run build:esm & npm run build:umd & npm run build:iife & npm run build:css & wait && echo \"Build complete:\nesm: $(gzip -c dist/formulate.esm.js | wc -c)b gzip\numd: $(gzip -c dist/formulate.umd.js | wc -c)b gzip\nmin: $(gzip -c dist/formulate.min.js | wc -c)b gzip\"", + "build": "npm run build:esm & npm run build:umd & npm run build:iife & npm run build:css & wait & npm run build:nuxt & wait && echo \"Build complete:\nesm: $(gzip -c dist/formulate.esm.js | wc -c)b gzip\numd: $(gzip -c dist/formulate.umd.js | wc -c)b gzip\nmin: $(gzip -c dist/formulate.min.js | wc -c)b gzip\"", "build:esm": "rollup --config build/rollup.config.js --format es --file dist/formulate.esm.js", "build:umd": "rollup --config build/rollup.config.js --format umd --file dist/formulate.umd.js", "build:iife": "rollup --config build/rollup.iife.config.js --format iife --file dist/formulate.min.js", "build:css": "node-sass themes/snow/snow.scss dist/snow.css && postcss --use autoprefixer -b '> 2%' < dist/snow.css | postcss --no-map --use cssnano > dist/snow.min.css", + "build:nuxt": "cp -r ./nuxt ./dist && uglifyjs --compress --mangle -o ./dist/nuxt/index.js -- ./nuxt/index.js", "test": "NODE_ENV=test jest --config test/jest.conf.js --coverage", "test:watch": "NODE_ENV=test jest --config test/jest.conf.js --watch", "test:coverage": "NODE_ENV=test jest --config test/jest.conf.js --coverage", @@ -79,6 +80,7 @@ "rollup-plugin-vue": "^5.1.9", "sass-loader": "^8.0.2", "typescript": "^3.9.7", + "uglify-es": "^3.3.9", "vue": "^2.6.12", "vue-jest": "^3.0.7", "vue-runtime-helpers": "^1.1.2", From 09226b9d4dc5ce2ee08b97fa197aa10236f4bba0 Mon Sep 17 00:00:00 2001 From: Andrew Boyd Date: Wed, 23 Dec 2020 19:36:52 -0500 Subject: [PATCH 2/3] updates nuxt module to expect external config file --- dist/nuxt/index.js | 2 +- dist/nuxt/plugin.js | 8 ++++++-- nuxt/index.js | 13 ++++++++++++- nuxt/plugin.js | 7 ++++++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/dist/nuxt/index.js b/dist/nuxt/index.js index 64363f1..e0fd565 100644 --- a/dist/nuxt/index.js +++ b/dist/nuxt/index.js @@ -1 +1 @@ -import path from"path";export default function nuxtVueFormulate(t){const o=Object.assign({},this.options.formulate,t);this.addPlugin({src:path.resolve(__dirname,"plugin.js"),options:o})}; \ No newline at end of file +import fs from"fs";import path from"path";export default function nuxtVueFormulate(t){let o=Object.assign({},this.options.formulate,t),i=!1;o.configPath?i=o.configPath:fs.existsSync(`${this.options.srcDir}/formulate.config.js`)&&(i="~/formulate.config.js"),o=Object.assign({},o,{configPath:i}),this.addPlugin({src:path.resolve(__dirname,"plugin.js"),options:o})}; \ No newline at end of file diff --git a/dist/nuxt/plugin.js b/dist/nuxt/plugin.js index 3772832..9c47b80 100644 --- a/dist/nuxt/plugin.js +++ b/dist/nuxt/plugin.js @@ -1,5 +1,9 @@ -/* eslint-disable */ import Vue from 'vue' import VueFormulate from '@braid/vue-formulate' +<% if (options.configPath) { %> +import options from '<%= options.configPath %>' +<% } else { %> +const options = {} +<% } %> -Vue.use(VueFormulate, <%= serialize(options) %>) +Vue.use(VueFormulate, options) diff --git a/nuxt/index.js b/nuxt/index.js index 2a943f3..26e454f 100644 --- a/nuxt/index.js +++ b/nuxt/index.js @@ -1,7 +1,18 @@ +import fs from 'fs' import path from 'path' export default function nuxtVueFormulate (moduleOptions) { - const formulateOptions = Object.assign({}, this.options.formulate, moduleOptions) + let formulateOptions = Object.assign({}, this.options.formulate, moduleOptions) + let configPath = false + // check if we have a user-provided config path + // or if a config file exists in the default location + if (formulateOptions.configPath) { + configPath = formulateOptions.configPath + } else if (fs.existsSync(`${this.options.srcDir}/formulate.config.js`)) { + configPath = '~/formulate.config.js' + } + // add the parsed config path back into the options object + formulateOptions = Object.assign({}, formulateOptions, { configPath }) // Register `plugin.js` template this.addPlugin({ src: path.resolve(__dirname, 'plugin.js'), diff --git a/nuxt/plugin.js b/nuxt/plugin.js index 7be3f6a..9c47b80 100644 --- a/nuxt/plugin.js +++ b/nuxt/plugin.js @@ -1,4 +1,9 @@ import Vue from 'vue' import VueFormulate from '@braid/vue-formulate' +<% if (options.configPath) { %> +import options from '<%= options.configPath %>' +<% } else { %> +const options = {} +<% } %> -Vue.use(VueFormulate, <%= serialize(options) %>) +Vue.use(VueFormulate, options) From 35b6836833e91072e0f4054fe5c4a26c8685a706 Mon Sep 17 00:00:00 2001 From: Andrew Boyd Date: Mon, 28 Dec 2020 11:38:49 -0500 Subject: [PATCH 3/3] remove nuxt build step and build assets --- dist/nuxt/index.js | 1 - dist/nuxt/plugin.js | 9 --------- package.json | 4 +--- 3 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 dist/nuxt/index.js delete mode 100644 dist/nuxt/plugin.js diff --git a/dist/nuxt/index.js b/dist/nuxt/index.js deleted file mode 100644 index e0fd565..0000000 --- a/dist/nuxt/index.js +++ /dev/null @@ -1 +0,0 @@ -import fs from"fs";import path from"path";export default function nuxtVueFormulate(t){let o=Object.assign({},this.options.formulate,t),i=!1;o.configPath?i=o.configPath:fs.existsSync(`${this.options.srcDir}/formulate.config.js`)&&(i="~/formulate.config.js"),o=Object.assign({},o,{configPath:i}),this.addPlugin({src:path.resolve(__dirname,"plugin.js"),options:o})}; \ No newline at end of file diff --git a/dist/nuxt/plugin.js b/dist/nuxt/plugin.js deleted file mode 100644 index 9c47b80..0000000 --- a/dist/nuxt/plugin.js +++ /dev/null @@ -1,9 +0,0 @@ -import Vue from 'vue' -import VueFormulate from '@braid/vue-formulate' -<% if (options.configPath) { %> -import options from '<%= options.configPath %>' -<% } else { %> -const options = {} -<% } %> - -Vue.use(VueFormulate, options) diff --git a/package.json b/package.json index c067c20..eaf1de6 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,11 @@ "./sfc": "src/Formulate.js" }, "scripts": { - "build": "npm run build:esm & npm run build:umd & npm run build:iife & npm run build:css & wait & npm run build:nuxt & wait && echo \"Build complete:\nesm: $(gzip -c dist/formulate.esm.js | wc -c)b gzip\numd: $(gzip -c dist/formulate.umd.js | wc -c)b gzip\nmin: $(gzip -c dist/formulate.min.js | wc -c)b gzip\"", + "build": "npm run build:esm & npm run build:umd & npm run build:iife & npm run build:css & wait && echo \"Build complete:\nesm: $(gzip -c dist/formulate.esm.js | wc -c)b gzip\numd: $(gzip -c dist/formulate.umd.js | wc -c)b gzip\nmin: $(gzip -c dist/formulate.min.js | wc -c)b gzip\"", "build:esm": "rollup --config build/rollup.config.js --format es --file dist/formulate.esm.js", "build:umd": "rollup --config build/rollup.config.js --format umd --file dist/formulate.umd.js", "build:iife": "rollup --config build/rollup.iife.config.js --format iife --file dist/formulate.min.js", "build:css": "node-sass themes/snow/snow.scss dist/snow.css && postcss --use autoprefixer -b '> 2%' < dist/snow.css | postcss --no-map --use cssnano > dist/snow.min.css", - "build:nuxt": "cp -r ./nuxt ./dist && uglifyjs --compress --mangle -o ./dist/nuxt/index.js -- ./nuxt/index.js", "test": "NODE_ENV=test jest --config test/jest.conf.js --coverage", "test:watch": "NODE_ENV=test jest --config test/jest.conf.js --watch", "test:coverage": "NODE_ENV=test jest --config test/jest.conf.js --coverage", @@ -80,7 +79,6 @@ "rollup-plugin-vue": "^5.1.9", "sass-loader": "^8.0.2", "typescript": "^3.9.7", - "uglify-es": "^3.3.9", "vue": "^2.6.12", "vue-jest": "^3.0.7", "vue-runtime-helpers": "^1.1.2",