Skip to content

Commit

Permalink
MAJOR: chore: vue3 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Jun 19, 2023
1 parent 6ec8fdb commit bd5865f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 200 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dist/*",
"components.js",
"plugin.js",
"plugin-vue3.js",
"screenshots/*"
],
"scripts": {
Expand Down Expand Up @@ -52,8 +51,7 @@
"rollup-plugin-css-only": "2.1.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-vue2": "npm:rollup-plugin-vue@^5.1.9",
"rollup-plugin-vue3": "npm:rollup-plugin-vue@^6.0.0",
"rollup-plugin-vue": "^6.0.0",
"sass": "^1.55.0",
"sass-loader": "^13.1.0",
"semantic-release": "^19.0.5",
Expand Down Expand Up @@ -86,4 +84,4 @@
"/node_modules/"
]
}
}
}
42 changes: 0 additions & 42 deletions plugin-vue3.js

This file was deleted.

6 changes: 3 additions & 3 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as Directives from "./dist/js/BIMDataDirectives/index.js";
*/
const pluginFactory = cfg => {
return {
install(Vue) {
install(app) {
// COMPONENTS
Object.entries(Components).forEach(([componentName, component]) => {
if (
Expand All @@ -25,14 +25,14 @@ const pluginFactory = cfg => {
!cfg.includedComponents ||
cfg.includedComponents.includes(componentName)
) {
Vue.component(componentName, component);
app.component(componentName, component);
}
});

// DIRECTIVES
if (!cfg || cfg.directives !== false) {
Object.entries(Directives).forEach(([directiveName, directive]) =>
Vue.directive(directiveName.split("BIMData")[1], directive)
app.directive(directiveName.split("BIMData")[1], directive)
);
}
},
Expand Down
155 changes: 4 additions & 151 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { terser } from "rollup-plugin-terser";
import vue2 from "rollup-plugin-vue2";
import vue3 from "rollup-plugin-vue3";
import css from "rollup-plugin-css-only";
import copy from "rollup-plugin-copy";
import vue from "rollup-plugin-vue";
import replace from "@rollup/plugin-replace";
import postcss from "rollup-plugin-postcss";
import alias from "@rollup/plugin-alias";
import image from "@rollup/plugin-image";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";

module.exports = [
...getDirectivesConfiguration(),
Expand All @@ -20,7 +14,6 @@ module.exports = [
function getDirectivesConfiguration() {
return [
{
// vue2
input: ["src/BIMDataDirectives/index.js"],
plugins: [terser()],
output: {
Expand All @@ -29,24 +22,13 @@ function getDirectivesConfiguration() {
},
external: ["vue"],
},
{
// vue3
input: ["src/BIMDataDirectives/vue3/index.js"],
plugins: [terser()],
output: {
dir: "dist/js/BIMDataDirectives/vue3",
format: "es",
},
external: ["vue"],
},
];
}

// build ALL COMPONENTS
function getAllComponentsBundleConfiguration() {
return [
{
// Vue 2
input: ["src/BIMDataComponents/index.js"],
output: {
dir: "dist/js/BIMDataComponents",
Expand All @@ -59,72 +41,7 @@ function getAllComponentsBundleConfiguration() {
delimiters: ["", ""],
preventAssignment: true,
}),
css({
output: "dist/css/design-system.css",
}),
copy({
targets: [
{
src: "src/assets/fonts",
dest: "dist",
},
{
src: "src/assets/scss",
dest: "dist",
},
{
src: "src/BIMDataComponents/BIMDataColorSelector/colors.js",
dest: "dist",
},
{
src: "src/assets/css/_BIMDataFonts.css",
dest: "dist/css",
rename: "fonts.css",
},
{
src: "src/assets/scss/_BIMDataFonts.scss",
dest: "dist/scss",
transform: contents =>
contents
.toString()
.replace(
/~@\/assets/g,
"node_modules/@bimdata/design-system/dist"
),
},
],
}),
vue2({
template: { isProduction: true },
css: false,
}),
image(),
terser(),
],
},
{
// Vue 3
input: ["src/BIMDataComponents/index.js"],
output: {
dir: "dist/js/BIMDataComponents/vue3",
format: "es",
},
external: ["vue"],
plugins: [
alias({
entries: [
{
find: /BIMDataDirectives\/(?!vue3\/)/,
replacement: "BIMDataDirectives/vue3/",
},
],
}),
replace({
"~@/assets": "node_modules/@bimdata/design-system/dist",
delimiters: ["", ""],
preventAssignment: true,
}),
vue3({
vue({
template: { isProduction: true },
preprocessStyles: true,
}),
Expand All @@ -141,7 +58,6 @@ function getSingleSmartComponentConfigurations() {
const componentNames = ["BIMDataFileManager"];

return [
// Build Vue 2.x compatible components
...componentNames.map(componentName => ({
input: [
`src/BIMDataSmartComponents/${componentName}/${componentName}.vue`,
Expand All @@ -150,46 +66,13 @@ function getSingleSmartComponentConfigurations() {
file: `dist/js/BIMDataSmartComponents/${componentName}.js`,
format: "esm",
},
external: ["vue"],
plugins: [
replace({
"~@/assets": "node_modules/@bimdata/design-system/dist",
delimiters: ["", ""],
preventAssignment: true,
}),
vue2({
template: { isProduction: true },
}),
resolve({ browser: true, preferBuiltins: false }),
commonjs(),
image(),
terser(),
],
})),
// Build Vue 3.x compatible components
...componentNames.map(componentName => ({
input: [
`src/BIMDataSmartComponents/${componentName}/${componentName}.vue`,
],
output: {
file: `dist/js/BIMDataSmartComponents/vue3/${componentName}.js`,
format: "esm",
},
plugins: [
alias({
entries: [
{
find: /BIMDataDirectives\//,
replacement: "BIMDataDirectives/vue3/",
},
],
}),
replace({
"~@/assets": "node_modules/@bimdata/design-system/dist",
delimiters: ["", ""],
preventAssignment: true,
}),
vue3({
vue({
template: { isProduction: true },
preprocessStyles: true,
}),
Expand Down Expand Up @@ -243,7 +126,6 @@ function getSingleComponentConfigurations() {
];

return [
// Build Vue 2.x compatible components
...componentNames.map(componentName => ({
input: [`src/BIMDataComponents/${componentName}/${componentName}.vue`],
output: {
Expand All @@ -257,36 +139,7 @@ function getSingleComponentConfigurations() {
delimiters: ["", ""],
preventAssignment: true,
}),
vue2({
template: { isProduction: true },
}),
image(),
terser(),
],
})),
// Build Vue 3.x compatible components
...componentNames.map(componentName => ({
input: [`src/BIMDataComponents/${componentName}/${componentName}.vue`],
output: {
file: `dist/js/BIMDataComponents/vue3/${componentName}.js`,
format: "esm",
},
external: ["vue"],
plugins: [
alias({
entries: [
{
find: /BIMDataDirectives\/(?!vue3\/)/,
replacement: "BIMDataDirectives/vue3/",
},
],
}),
replace({
"~@/assets": "node_modules/@bimdata/design-system/dist",
delimiters: ["", ""],
preventAssignment: true,
}),
vue3({
vue({
template: { isProduction: true },
preprocessStyles: true,
}),
Expand Down

0 comments on commit bd5865f

Please sign in to comment.