Giter VIP home page Giter VIP logo

craft-vue's Introduction

craft-vue

All the power of Vue CLI's scaffolding & single file components tailored for a Craft CMS project.

What's Included

  • npm run dev / yarn dev: first-in-class development experience.

    • Webpack + vue-loader for single file Vue components
    • State preserving hot-reload
    • Page reloading on file edits (twig, html, etc)
    • State preserving compilation error overlay
    • Lint-on-save with ESLint
    • Source maps
  • npm run build / yarn build: Production ready build.

    • JavaScript minification with UglifyJS v3
    • Babel compiling
    • CSS across all components extracted into a single file and minified with cssnano
    • Static assets compiled with version hashes for efficient long-term caching
    • Bundle size analytics

Fork It And Make Your Own

You should fork this repo to create your own boilerplate. This scaffold makes no assumptions about pre-processor, babel, or linting configurations.

I've also created a fork of this boilerplate that integrates TailwindCSS & Purgecss.

Setup

This boilerplate requires Vue CLI 3 be installed globally on your machine.

# create & install project
composer create-project chasegiunta/craft-vue PATH

# run Craft's setup & install
./craft setup

# install the Asset Rev plugin
./craft install/plugin assetrev

# install dependencies
npm install # yarn

# run dev server (default runs on localhost:8080)
npm run dev # yarn dev (alias for 'yarn serve')

# build for production with minification
npm run build # yarn build

Once up and running, the fun part comes in using Vue CLI's GUI to customize your project to suite your needs. Simply run vue ui and import your newly created project to get started.

You can also run your dev & build tasks from the GUI to get valuable build stats & runtime analytics.

NOTE: During development, only your assets will be served from localhost:8080 and referenced in the base template. You'll still load your site locally under your normal development domain (mysite.test, etc.). This will also cause a brief unstyled flash on page loads due to JS/CSS assets loading from javascript for development. This flash isn't present after build, on production.

After running npm run build, the easiest way to test your build files locally is to comment the environment variable in your .env file, and refresh the page. This will serve your assets from the build directory, rather than webpack's dev server.

For a detailed explanation on how things work, check out the Vue CLI docs.

Pre-Processors

This boilerplate has pre-configured CSS extraction for most popular CSS pre-processors including LESS, SASS, Stylus, and PostCSS. To use a pre-processor, all you need to do is install the appropriate webpack loader for it. For example, to use SASS:

npm install sass-loader node-sass --save-dev
# yarn add sass-loader node-sass --dev

Note you also need to install node-sass because sass-loader depends on it as a peer dependency.

Read more about this at https://cli.vuejs.org/guide/css.html#pre-processors

Automatic Component Registration

Any vue components placed within src/components will be registered with Vue automatically. This requires their filenames to be in PascalCase, eg. MyVueComponent.vue

Babel Compiling

This boilerplate uses babel-preset-env for configuring babel. You can read more about it here.

Linting

You can enable linting by adding the @vue/cli-plugin-eslint plugin through the GUI vue ui.

craft-vue's People

Contributors

brandonkelly avatar chasegiunta avatar angrybrad avatar carlcs avatar benjamindavid avatar mildlygeeky avatar jasonmccallister avatar geenious avatar cromwellryan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.