Coder Social home page Coder Social logo

sails-hook-vuewebpack's Introduction

sails-hook-vuewebpack

Sails.js hook that provides a Vue.js frontend using webpack.

Install

npm install sails-hook-vuewebpack --save

Getting started

You have to create your Sails project using the --no-frontend option or disable the grunt hook in your .sailsrc

  "hooks": {
    "grunt": false
  }

Configure babel by copying the following lines in the .babelrc file at the root of your project's folder

{
  "presets": ["es2015", "stage-2"],
  "plugins": ["transform-runtime"],
  "comments": false
}

Create a src folder where you'll place your main.js and *.vue source files, the index file index.html and your frontend assets directory assets.

Refer to the Vue.js documentation for the content of these files.

How it works

Upon initialization, the hook creates a fresh copy of src/assets in .tmp/public/assets, then compiles src/main.js (and its dependencies) into .tmp/public/js/build/bundle.js and finally links that bundle in .tmp/public/index.html by replacing the <!-- #scripts --> / <!-- #end --> tags from src/index.html with the proper markup to include the compiled script.

When lifted, Sails will serve the content of .tmp/public on the standard port, which corresponds to your frontend index file.

In development mode, the hook serves a dynamic copy of the bundle using webpack-dev-server on port 3000. This provides Hot Module Replacement (HMR) functionality, i.e. changes in source files are reflected automatically in the browser without the need to refresh the page.

In production mode, the bundle is served from the compiled static file .tmp/public/js/build/bundle.js.

sails-hook-vuewebpack's People

Contributors

pascalanimateur avatar

Watchers

 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.