├── DOCS.md ├── DOMAIN.md ├── demo.jpg ├── template ├── static │ ├── example.jpg │ ├── favicon.ico │ └── README.md ├── .gitignore ├── plugins │ ├── element.js │ ├── vuex.js │ └── README.md ├── store │ ├── index.js │ └── README.md ├── backpack.config.js ├── components │ ├── README.md │ └── AppLogo.vue ├── .editorconfig ├── api │ ├── hello.js │ └── index.js ├── app │ ├── admin │ │ ├── layouts │ │ │ ├── README.md │ │ │ └── default.vue │ │ ├── pages │ │ │ ├── README.md │ │ │ └── index.vue │ │ ├── app.config.js │ │ └── index.js │ └── blog │ │ ├── layouts │ │ ├── README.md │ │ └── default.vue │ │ ├── pages │ │ ├── README.md │ │ └── index.vue │ │ ├── app.config.js │ │ └── index.js ├── assets │ ├── README.md │ └── scss │ │ └── style.scss ├── middleware │ └── README.md ├── README.md ├── .eslintrc.js ├── package.json └── nuxt.config.js ├── LICENSE ├── README.md └── meta.js /DOCS.md: -------------------------------------------------------------------------------- 1 | # Documentations 2 | 3 | Nope -------------------------------------------------------------------------------- /DOMAIN.md: -------------------------------------------------------------------------------- 1 | # Virtual Host Setting 2 | 3 | Nope -------------------------------------------------------------------------------- /demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hibuno/nuxt-multiple/HEAD/demo.jpg -------------------------------------------------------------------------------- /template/static/example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hibuno/nuxt-multiple/HEAD/template/static/example.jpg -------------------------------------------------------------------------------- /template/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hibuno/nuxt-multiple/HEAD/template/static/favicon.ico -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | 4 | # logs 5 | npm-debug.log 6 | 7 | # Nuxt build 8 | .nuxt 9 | 10 | # Nuxt generate 11 | dist 12 | -------------------------------------------------------------------------------- /template/plugins/element.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import ElementUI from 'element-ui' 3 | import locale from 'element-ui/lib/locale/lang/en' 4 | 5 | Vue.use(ElementUI, { locale }) 6 | -------------------------------------------------------------------------------- /template/plugins/vuex.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import vuexStore from 'store' 3 | 4 | Vue.mixin({ 5 | computed: { 6 | store () { 7 | return vuexStore 8 | } 9 | } 10 | }) 11 | -------------------------------------------------------------------------------- /template/store/index.js: -------------------------------------------------------------------------------- 1 | const state = () => ({ 2 | message: 'Hello from Vuex!' 3 | }) 4 | 5 | const mutations = { 6 | // Some Vuex mutations here 7 | } 8 | 9 | export default { 10 | state, 11 | mutations 12 | } 13 | -------------------------------------------------------------------------------- /template/backpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: (config, options, webpack) => { 3 | config.entry.main = [ 4 | './app/blog/index.js', 5 | './app/admin/index.js' 6 | ] 7 | 8 | return config 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /template/components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | 3 | The components directory contains your Vue.js Components. 4 | Nuxt.js doesn't supercharge these components. 5 | 6 | **This directory is not required, you can delete it if you don't want to use it.** 7 | 8 | -------------------------------------------------------------------------------- /template/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /template/api/hello.js: -------------------------------------------------------------------------------- 1 | import Router from 'express/lib/router/index' 2 | 3 | const router = Router() 4 | 5 | /** 6 | * Create root endpoint 7 | */ 8 | router.get('/', async (req, res) => { 9 | res.json({ 10 | message: 'Hello from API!' 11 | }) 12 | }) 13 | 14 | export default router 15 | -------------------------------------------------------------------------------- /template/api/index.js: -------------------------------------------------------------------------------- 1 | import { Router } from 'express' 2 | 3 | /** 4 | * Import any routes 5 | */ 6 | import hello from './hello' 7 | 8 | /** 9 | * Create new Instance of Router 10 | */ 11 | const router = Router() 12 | 13 | /** 14 | * User routes here 15 | */ 16 | router.use(hello) 17 | 18 | export default router 19 | -------------------------------------------------------------------------------- /template/app/admin/layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | This directory contains your Application Layouts. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/views#layouts 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | 10 | -------------------------------------------------------------------------------- /template/app/blog/layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | This directory contains your Application Layouts. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/views#layouts 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | 10 | -------------------------------------------------------------------------------- /template/app/admin/pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the .vue files inside this directory and creates the router of your application. 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing 8 | 9 | -------------------------------------------------------------------------------- /template/app/blog/pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the .vue files inside this directory and creates the router of your application. 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing 8 | 9 | -------------------------------------------------------------------------------- /template/assets/README.md: -------------------------------------------------------------------------------- 1 | # ASSETS 2 | 3 | This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/assets#webpacked 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | 10 | -------------------------------------------------------------------------------- /template/plugins/README.md: -------------------------------------------------------------------------------- 1 | # PLUGINS 2 | 3 | This directory contains your Javascript plugins that you want to run before instantiating the root vue.js application. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/plugins 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | 10 | -------------------------------------------------------------------------------- /template/app/blog/app.config.js: -------------------------------------------------------------------------------- 1 | const merge = require('deepmerge') 2 | const nuxt = require('../../nuxt.config.js') 3 | 4 | const extend = { 5 | /** 6 | * Define source directory 7 | */ 8 | srcDir: __dirname, 9 | /** 10 | * Define build target 11 | */ 12 | buildDir: '.nuxt/blog' 13 | } 14 | 15 | /** 16 | * Export config 17 | */ 18 | 19 | module.exports = merge(nuxt, extend) 20 | -------------------------------------------------------------------------------- /template/static/README.md: -------------------------------------------------------------------------------- 1 | # STATIC 2 | 3 | This directory contains your static files. 4 | Each file inside this directory is mapped to /. 5 | 6 | Example: /static/robots.txt is mapped as /robots.txt. 7 | 8 | More information about the usage of this directory in the documentation: 9 | https://nuxtjs.org/guide/assets#static 10 | 11 | **This directory is not required, you can delete it if you don't want to use it.** 12 | 13 | -------------------------------------------------------------------------------- /template/middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | This directory contains your Application Middleware. 4 | The middleware lets you define custom function to be ran before rendering a page or a group of pages (layouts). 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing#middleware 8 | 9 | **This directory is not required, you can delete it if you don't want to use it.** 10 | 11 | -------------------------------------------------------------------------------- /template/store/README.md: -------------------------------------------------------------------------------- 1 | # STORE 2 | 3 | This directory contains your Vuex Store files. 4 | Vuex Store option is implemented in the Nuxt.js framework. 5 | Creating a index.js file in this directory activate the option in the framework automatically. 6 | 7 | More information about the usage of this directory in the documentation: 8 | https://nuxtjs.org/guide/vuex-store 9 | 10 | **This directory is not required, you can delete it if you don't want to use it.** 11 | 12 | -------------------------------------------------------------------------------- /template/app/admin/app.config.js: -------------------------------------------------------------------------------- 1 | const merge = require('deepmerge') 2 | const nuxt = require('../../nuxt.config.js') 3 | 4 | const extend = { 5 | /** 6 | * Define source directory 7 | */ 8 | srcDir: __dirname, 9 | /** 10 | * Define build target 11 | */ 12 | buildDir: '.nuxt/admin', 13 | 14 | /** 15 | * Custom head title 16 | */ 17 | head: { 18 | title: 'Admin Page' 19 | } 20 | } 21 | 22 | /** 23 | * Export config 24 | */ 25 | 26 | module.exports = merge(nuxt, extend) 27 | -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # nuxt-multiple-app 2 | 3 | > {{ description }} 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | $ npm install # Or yarn install 10 | 11 | # serve with hot reload at localhost:3000 12 | $ npm run dev 13 | 14 | # build for production and launch server 15 | $ npm run build 16 | $ npm start 17 | 18 | # generate static project 19 | $ npm run generate 20 | ``` 21 | 22 | For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js). 23 | 24 | -------------------------------------------------------------------------------- /template/assets/scss/style.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Write your SCSS code here 3 | */ 4 | body { 5 | font-family: 'Open Sans', sans-serif; 6 | font-size: 1rem; 7 | } 8 | .main { 9 | margin-top: 15%; 10 | } 11 | .main-content { 12 | background-color: #FAFAFA; 13 | 14 | .main { 15 | margin-top: 10%; 16 | } 17 | } 18 | .el-aside { 19 | height: 100vh; 20 | } 21 | .title { 22 | font-size: 3rem; 23 | font-weight: 300; 24 | margin: 1rem 0; 25 | 26 | &-small { 27 | font-size: 1.4rem; 28 | margin-bottom: 1rem; 29 | font-weight: 500; 30 | } 31 | } -------------------------------------------------------------------------------- /template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | browser: true, 5 | node: true 6 | }, 7 | parserOptions: { 8 | parser: 'babel-eslint' 9 | }, 10 | extends: [ 11 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 12 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 13 | 'plugin:vue/essential', 14 | 'standard' 15 | ], 16 | // required to lint *.vue files 17 | plugins: [ 18 | 'vue' 19 | ], 20 | // add your custom rules here 21 | rules: {} 22 | } 23 | -------------------------------------------------------------------------------- /template/app/blog/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /template/app/blog/pages/index.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 NUXT 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Preview](demo.jpg) 2 | 3 | # Nuxt Template 4 | 5 | A [Nuxt.js](https://github.com/nuxt/nuxt.js) starter project template without the distraction of a complicated development environment. 6 | 7 | ## Prerequisites 8 | 9 | Make sure to have `node 8.0+` and `npm 5.0+` installed 10 | 11 | ## Installation 12 | 13 | This is a project template for [vue-cli](https://github.com/vuejs/vue-cli). 14 | 15 | ``` bash 16 | $ vue init muhibbudins/nuxt-multiple my-project 17 | $ cd my-project 18 | 19 | # install dependencies 20 | $ npm install # Or yarn install 21 | ``` 22 | 23 | > Make sure to use a version of vue-cli >= 2.1 (`vue -V`). 24 | 25 | ## Usage 26 | 27 | ### Development 28 | 29 | ``` bash 30 | # serve with hot reloading at localhost:3000 31 | $ npm run dev # Or yarn dev 32 | ``` 33 | 34 | Go to [http://localhost:3000](http://localhost:3000) 35 | 36 | ### Production 37 | 38 | ``` bash 39 | # build for production and launch the server 40 | $ npm run build 41 | $ npm start 42 | ``` 43 | 44 | ## Feature 45 | 46 | This template already include with : 47 | 48 | - Express Backpack 49 | - Element UI 50 | - Axios & Example APIs 51 | - SASS / SCSS Loader 52 | - Vuex Store 53 | -------------------------------------------------------------------------------- /template/app/admin/pages/index.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 44 | -------------------------------------------------------------------------------- /template/app/admin/index.js: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import { Nuxt, Builder } from 'nuxt' 3 | import bodyParser from 'body-parser' 4 | 5 | /** 6 | * Import any Routes on API folder 7 | */ 8 | import api from '../../api' 9 | 10 | const app = express() 11 | const host = process.env.HOST || '127.0.0.1' 12 | const port = process.env.PORT || 3060 13 | 14 | /** 15 | * Set port 16 | */ 17 | app.set('port', port) 18 | 19 | /** 20 | * Use body parser for handling POST method 21 | */ 22 | app.use(bodyParser.json()) 23 | 24 | /** 25 | * Use given APIs 26 | */ 27 | app.use('/api', api) 28 | 29 | /** 30 | * Import and use Nuxt.js configuration 31 | */ 32 | let config = require('./app.config.js') 33 | config.dev = !(process.env.NODE_ENV === 'production') 34 | 35 | /** 36 | * Create new instance of Nuxt 37 | */ 38 | const nuxt = new Nuxt(config) 39 | 40 | /** 41 | * Set build only on development mode 42 | */ 43 | if (config.dev) { 44 | const builder = new Builder(nuxt) 45 | builder.build() 46 | } 47 | 48 | /** 49 | * Use Nuxt renderer on Express 50 | */ 51 | app.use(nuxt.render) 52 | 53 | /** 54 | * Start App 55 | */ 56 | app.listen(port, host) 57 | 58 | /** 59 | * Show listen port 60 | */ 61 | console.log(`App "Admin" listening on ${host}:${port}`) 62 | -------------------------------------------------------------------------------- /template/app/blog/index.js: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import { Nuxt, Builder } from 'nuxt' 3 | import bodyParser from 'body-parser' 4 | 5 | /** 6 | * Import any Routes on API folder 7 | */ 8 | import api from '../../api' 9 | 10 | const app = express() 11 | const host = process.env.HOST || '127.0.0.1' 12 | const port = process.env.PORT || 3050 13 | 14 | /** 15 | * Set port 16 | */ 17 | app.set('port', port) 18 | 19 | /** 20 | * Use body parser for handling POST method 21 | */ 22 | app.use(bodyParser.json()) 23 | 24 | /** 25 | * Use given APIs 26 | */ 27 | app.use('/api', api) 28 | 29 | /** 30 | * Import and use Nuxt.js configuration 31 | */ 32 | let config = require('./app.config.js') 33 | config.dev = !(process.env.NODE_ENV === 'production') 34 | 35 | /** 36 | * Create new instance of Nuxt 37 | */ 38 | const nuxt = new Nuxt(config) 39 | 40 | /** 41 | * Set build only on development mode 42 | */ 43 | if (config.dev) { 44 | const builder = new Builder(nuxt) 45 | builder.build() 46 | } 47 | 48 | /** 49 | * Use Nuxt renderer on Express 50 | */ 51 | app.use(nuxt.render) 52 | 53 | /** 54 | * Start App 55 | */ 56 | app.listen(port, host) 57 | 58 | /** 59 | * Show listen port 60 | */ 61 | console.log(`App "Blog" listening on ${host}:${port}`) 62 | -------------------------------------------------------------------------------- /template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{ name }}", 3 | "version": "1.0.0", 4 | "description": "{{ description }}", 5 | "author": "{{ author }}", 6 | "private": true, 7 | "scripts": { 8 | "dev": "backpack dev", 9 | "build": "nuxt build --config-file app/admin/app.config.js && nuxt build --config-file app/blog/app.config.js && backpack build", 10 | "start": "cross-env NODE_ENV=production node build/main.js", 11 | "precommit": "npm run lint", 12 | "lint": "eslint --ext .js,.vue --ignore-path .gitignore ." 13 | }, 14 | "dependencies": { 15 | "axios": "^0.18.0", 16 | "backpack-core": "^0.7.0", 17 | "body-parser": "^1.18.3", 18 | "cross-env": "^5.2.0", 19 | "deepmerge": "^2.1.1", 20 | "element-ui": "^2.4.6", 21 | "express": "^4.16.3", 22 | "nuxt": "^1.4.0", 23 | "source-map-support": "^0.5.8", 24 | "vuex": "^3.0.1" 25 | }, 26 | "devDependencies": { 27 | "node-sass": "^4.9.2", 28 | "sass-loader": "^7.0.3", 29 | "babel-eslint": "^7.2.3", 30 | "eslint": "^4.3.0", 31 | "eslint-config-standard": "^10.2.1", 32 | "eslint-loader": "^1.9.0", 33 | "eslint-plugin-html": "^3.1.1", 34 | "eslint-plugin-import": "^2.7.0", 35 | "eslint-plugin-node": "^5.1.1", 36 | "eslint-plugin-vue": "^4.7.1", 37 | "eslint-plugin-promise": "^3.5.0", 38 | "eslint-plugin-standard": "^3.0.1" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /meta.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | helpers: { 3 | escape: function(value) { 4 | return value.replace(/'/g, '''); 5 | } 6 | }, 7 | prompts: { 8 | name: { 9 | 'type': 'string', 10 | 'required': true, 11 | 'message': 'Project name:' 12 | }, 13 | description: { 14 | 'type': 'string', 15 | 'required': false, 16 | 'message': 'Project description:', 17 | 'default': 'A Nuxt.js project' 18 | }, 19 | author: { 20 | 'type': 'string', 21 | 'message': 'Author:' 22 | } 23 | }, 24 | complete (data, {logger, chalk}) { 25 | let message = ` 26 | ${chalk.green.bold('Multiple Nuxt')} already installed 27 | 28 | This projects already have dummy projects 29 | inside ${chalk.green.bold('app')} directory. 30 | 31 | With details: 32 | 33 | - App Name : Blog 34 | Source : app/blog/ 35 | Listen On : 127.0.0.1:3050 36 | 37 | - App Name : Admin 38 | Source : app/admin/ 39 | Listen On : 127.0.0.1:3060 40 | 41 | ` 42 | 43 | if (!data.inPlace) { 44 | message += ` 45 | To get started: 46 | 47 | cd ${data.destDirName} 48 | npm install # Or yarn 49 | npm run dev 50 | ` 51 | } else { 52 | message += ` 53 | To get started: 54 | 55 | npm install # Or yarn 56 | npm run dev 57 | ` 58 | } 59 | 60 | logger.log(` 61 | ${message} 62 | 63 | -------------------------------- 64 | 65 | Thanks for using ${chalk.green.bold('Multiple Nuxt')} 66 | Learn more at https://github.com/muhibbudins/nuxt-multiple 67 | 68 | Made with ${chalk.red.bold('♥')} by ${chalk.bold('@muhibbudins')} 69 | `) 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /template/components/AppLogo.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 80 | -------------------------------------------------------------------------------- /template/app/admin/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 51 | -------------------------------------------------------------------------------- /template/nuxt.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const shared = [ 3 | 'assets', 4 | 'components', 5 | 'layout', 6 | 'middleware', 7 | 'plugins', 8 | 'static', 9 | 'store' 10 | ] 11 | 12 | module.exports = { 13 | /* 14 | ** Headers of the page 15 | */ 16 | head: { 17 | title: '{{ name }}', 18 | meta: [ 19 | { charset: 'utf-8' }, 20 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 21 | { hid: 'description', name: 'description', content: '{{ escape description }}' } 22 | ], 23 | link: [ 24 | { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }, 25 | { rel: 'stylesheet', type: 'text/css', href: '//cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' }, 26 | { rel: 'stylesheet', type: 'text/css', href: '//fonts.googleapis.com/css?family=Open+Sans:300|500' } 27 | ] 28 | }, 29 | /* 30 | ** Customize the progress bar color 31 | */ 32 | loading: { 33 | color: '#3B8070' 34 | }, 35 | /* 36 | ** Global CSS 37 | */ 38 | css: [ 39 | 'element-ui/lib/theme-chalk/index.css', 40 | { src: '../../assets/scss/style.scss', lang: 'scss' } 41 | ], 42 | /* 43 | ** Global Plugin 44 | */ 45 | plugins: [ 46 | '../../plugins/element.js', 47 | '../../plugins/vuex.js', 48 | '../../store/index.js' 49 | ], 50 | /* 51 | ** Global Module 52 | */ 53 | modules: [ 54 | // do stuff 55 | ], 56 | /* 57 | ** Build configuration 58 | */ 59 | build: { 60 | extractCSS: true, 61 | /* 62 | ** Run ESLint on save 63 | */ 64 | extend (config, ctx) { 65 | shared.map(item => { 66 | config.resolve.alias[item] = path.resolve(__dirname, item) 67 | }) 68 | 69 | if (ctx.isClient) { 70 | config.module.rules.push({ 71 | enforce: 'pre', 72 | test: /\.(js|vue)$/, 73 | loader: 'eslint-loader', 74 | exclude: /(node_modules)/ 75 | }) 76 | 77 | const vueLoader = config.module.rules.find(({loader}) => loader === 'vue-loader') 78 | const { options: {loaders} } = vueLoader || { options: {} } 79 | 80 | if (loaders) { 81 | for (const loader of Object.values(loaders)) { 82 | changeLoaderOptions(Array.isArray(loader) ? loader : [loader]) 83 | } 84 | } 85 | 86 | config.module.rules.forEach(rule => changeLoaderOptions(rule.use)) 87 | } 88 | } 89 | } 90 | } 91 | 92 | const changeLoaderOptions = (loaders) => { 93 | if (loaders) { 94 | for (const loader of loaders) { 95 | if (loader.loader === 'sass-loader') { 96 | Object.assign(loader.options, { 97 | includePaths: ['./assets'] 98 | }) 99 | } 100 | } 101 | } 102 | } 103 | --------------------------------------------------------------------------------