Vue Repo Setup
Creating the Repository
Command to create the repository:
npm create vite@latest repository-name -- --template vueEntering the Repository
code repository-namePreliminary Commands
npm inpm run devOnce the commands are executed, try accessing the page.
Deleting Files
- Delete the
style.cssfile. - Remove line 2 from the
main.jsfile (the line importing the CSS file). - Delete the
HelloWord.vuefile. - Empty the
App.vuefile. - Add the Vue boilerplate inside
App.vue. - Remove the Vite logo from the
index.htmlfile. - Change the title in the
index.htmlfile.
Installing SASS
npm i sass -D- Inside the
assetsfolder, create thescssfolder. - Inside
scss, create thestyle.scssfile. - Inside the
App.vuefile, setlang="scss"in the<style>tag. - Import the
style.scssfile inside the<style>tag:
@use './assets/scss/style.scss';Adding an Alias for the Path (@)
Import the path module in vite.config.js:
import path from 'path';Inside the defineConfig function, add the resolve object:
resolve: { alias: { '@': path.resolve(__dirname, 'src') }}Creating a vars.scss File for SCSS Variables
- Create the
vars.scssfile. - Import the
vars.scssfile where variables are needed:
@use 'vars' as *;Importing Bootstrap
npm i bootstrapImport Bootstrap in the main.js file:
import 'bootstrap/dist/css/bootstrap.min.css';FontAwesome
- Install FontAwesome:
Terminal window npm i --save @fortawesome/fontawesome-svg-core - Install the three icon packs:
Terminal window npm i --save @fortawesome/free-solid-svg-iconsnpm i --save @fortawesome/free-regular-svg-iconsnpm i --save @fortawesome/free-brands-svg-icons - Install the library:
Terminal window npm i --save @fortawesome/vue-fontawesome@latest-3 - Import the FontAwesome library:
import { library } from '@fortawesome/fontawesome-svg-core';
- Import the FontAwesome component:
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
- Import the icons you need:
import { iconName } from '@fortawesome/free-solid-svg-icons';import { iconName } from '@fortawesome/free-regular-svg-icons';import { iconName } from '@fortawesome/free-brands-svg-icons';
- Add icons globally:
Add alibrary.add(iconName);
library.add(iconName);for each icon pack (solid, regular, brands). - Make the icons available:
const app = createApp(App);app.component('FontAwesomeIcon', FontAwesomeIcon);app.mount('#app');
Fontsource
npm i @fontsource/font-nameImport Fontsource in the main.js file:
import '@fontsource/font-name';- Create a variable for the installed font.
- Use the variable in the
font-family.
Axios
npm i axios