# sails-hook-webpack4vue2

> build SPA with webpack and vue for sails

Latest version **2.2.7** (published 2019-01-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install sails-hook-webpack4vue2
pnpm add sails-hook-webpack4vue2
yarn add sails-hook-webpack4vue2
bun add sails-hook-webpack4vue2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.7 |
| Published | 2019-01-31 |
| First published | 2019-01-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 (+4 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dtnet |
| Maintainers | dtnet |
| Keywords | sails, webpack, vue |

## Links

- npm: https://www.npmjs.com/package/sails-hook-webpack4vue2
- Repository: https://github.com/dtnet/sailswebpack4vue2
- Homepage: https://github.com/dtnet/sailswebpack4vue2#readme
- Issues: https://github.com/dtnet/sailswebpack4vue2/issues
- npm.io page: https://npm.io/package/sails-hook-webpack4vue2

## Dependencies (10)

- [vue](https://npm.io/package/vue.md) ^2.5.21
- [vuex](https://npm.io/package/vuex.md) ^3.0.1
- [node-sass](https://npm.io/package/node-sass.md) ^4.11.0
- [vue-router](https://npm.io/package/vue-router.md) ^3.0.1
- [sass-loader](https://npm.io/package/sass-loader.md) ^7.1.0
- [@vue/cli-service](https://npm.io/package/@vue/cli-service.md) ^3.3.0
- [vue-template-compiler](https://npm.io/package/vue-template-compiler.md) ^2.5.21
- [webpack-dev-middleware](https://npm.io/package/webpack-dev-middleware.md) ^3.5.1
- [webpack-hot-middleware](https://npm.io/package/webpack-hot-middleware.md) ^2.24.3
- [connect-history-api-fallback](https://npm.io/package/connect-history-api-fallback.md) ^1.6.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 2.2.7 (latest) — 2019-01-31
- 2.2.6 — 2019-01-31
- 2.1.6 — 2019-01-31
- 2.0.6 — 2019-01-31
- 2.0.5 — 2019-01-30
- 2.0.4 — 2019-01-30
- 2.0.3 — 2019-01-30
- 2.0.2 — 2019-01-30
- 2.0.1 — 2019-01-30
- 2.0.0 — 2019-01-30
- 1.0.4 — 2019-01-28
- 1.0.3 — 2019-01-28
- 1.0.2 — 2019-01-28
- 1.0.1 — 2019-01-27
- 1.0.0 — 2019-01-27

## README

# sailswebpack4vue2
## build sails with nofrontend
````
sails new <project name> --no-frontend
cd <project name>
npm i sails-hook-webpack4vue2
````
## config static dir
````
# config/local.js or .sailsrc
  paths:{
    public: 'public'
  }
  # or
  "paths": {
    "public": "public"
  }
````
## config webpack
````
# vue.config.js
module.exports = {
  configureWebpack: config => {
    if (sails.config.environment === 'development') {
      /* HMR */
      config.entry = {
        app: ['./src/main.js', 'webpack-hot-middleware/client?reload=true']
      }
    } else {
      /* config for production mode */
    }
  }
}
````
````
mkdir public
# public/index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>vuecli</title>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but vuecli doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>
````
````
mkdir src
# src/main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
````
````
# src/router.js
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    }
  ]
})
````
````
# src/store.js
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {

  },
  mutations: {

  },
  actions: {

  }
})

````
````
# src/App.vue
<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
    </div>
    <router-view/>
  </div>
</template>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
</style>
````
[config webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware)
````
# config/webpackdev.js
module.exports.webpackdev = {
  /* config */
}
````
[config webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware)
````
# config/webpackhot.js
module.exports.webpackhot = {
  /* config */
}
````

---
_Source: https://npm.io/package/sails-hook-webpack4vue2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
