Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue template: update to latest @vue/cli #19

Merged
merged 1 commit into from
Sep 13, 2023
Merged

Conversation

fvsch
Copy link
Contributor

@fvsch fvsch commented Sep 13, 2023

This updates the vue template (EngineBlock) to use the latest @vue/cli (v5, instead of v4).

Goals and technical choices

My goal was to make sure that a downloaded project could install and run with Node and npm with no friction. In my tests, the current template worked, but logged incompatible runtime warnings with Node 18 (some dependency was marked as compatible with Node up to 16; Node 16 is end-of-life as of this week).

Note that Vue CLI, which wraps webpack, is in maintenance mode. The Vue project currently recommends using Vite instead. But the coding conventions for the project's index.html used by Vite are not compatible with EngineBlock at this time (see #18 for a similar issue with our React templates), so for now we should keep using @vue/cli in the template's devDependencies.

Methodology for this update

I created a new @vue/cli project with:

npx @vue/cli create hello-world

In the project creation wizard, I chose a custom config, and disabled ESLint (by default the two enabled plugins are babel and eslint).

My rationale for this was: we don't run linting on EngineBlock or in the StackBlitz classic editor, and we'd like to keep the dependencies down to a minimum. Do push back if you think we do need eslint.

Vue CLI project creation wizard, showing several options such as Babel, TypeScript, ESLint and more, with only Babel selected

Then I copied from the generated files into the vue template, trying to respect the modifications we had done before.

@fvsch fvsch requested review from sulco and donmckenna September 13, 2023 09:02
Comment on lines -13 to +14
"@vue/cli-plugin-babel": "^4.4.0",
"@vue/cli-plugin-eslint": "^4.4.0",
"@vue/cli-service": "^4.4.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
"core-js": "^3.32.2",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-service": "^5.0.8"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that the dependencies get quite simpler.

Note that the project generated by @vue/cli@5 put core-js in the dependencies, and I moved it to devDependencies because as far as I am aware it is only used by the Babel config used by @vue/cli-plugin-babel to inject ECMAScript polyfills at build time. We don't want to download it as a dependency when running in EngineBlock.

For a guide and recipes on how to configure / customize this project,<br>
check out the
For a guide and recipes on how to configure / customize this project, check out the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forced line break looks strange in narrow windows (such as in the editor's preview pane).

Comment on lines -1 to 2
const { createApp } = require('vue');
import { createApp } from 'vue';
import App from './App.vue';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't even notice that we had mixed imports/requires.

Comment on lines +5 to +6
width="200"
height="200"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Longstanding issue with our Vue starter template: logo looks too big. Because:

  • In the original project generated by @vue/cli, there is a src/assets/logo.png file. Because storing binary files in StackBlitz is a paid feature, we modified that to link to https://vuejs.org/images/logo.png
  • The src/assets/logo.png file was 200x200, but the image we link to is 400x400, and ends up looking way too big in the preview iframe in our classic editor.

Other options that don't require hotlinking to the vuejs.org site:

  1. Include a SVG logo as src/assets/logo.svg. Problem: EngineBlock doesn't seem to support it, at least not in the vue-cli preset.
  2. Include the logo as inline SVG in the template. That one is doable, and the Vue logo can be tiny as SVG:
<svg viewBox="0 0 16 16" width="200" height="200">
  <path d="M9.85 1.07L8 4.27l-1.85-3.2H0l8 13.86 8-13.86H9.85z" fill="#41B883"/>
  <path d="M9.85 1.07L8 4.27l-1.85-3.2H3.2L8 9.4l4.8-8.32H9.85z" fill="#34495E"/>
</svg>

For now I'm keeping the hotlinked PNG, but if we want to go with inline SVG (maybe even as a VueLogo.vue component that takes a size prop?) that works too.

@fvsch fvsch merged commit 2c36b3b into main Sep 13, 2023
1 check passed
@fvsch fvsch deleted the fvsch/update-vite-starter branch September 13, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants