-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
146 lines (142 loc) · 3.78 KB
/
nuxt.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const nodeExternals = require('webpack-node-externals')
const path = require('path')
module.exports = {
router: {
base: '/'
},
manifest: {
theme_color: '#000000'
},
/*
** Headers of the page
*/
head: {
title: './tiny/',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
]
},
/*
** Global Styles
*/
css: [
{
src: '~assets/styles/global.scss',
lang: 'scss'
}
],
/*
** Customize the progress-bar color
*/
loading: {
color: '#25c163',
failedColor: '#e9494f',
height: '4px'
},
generate: {
/*
** Generate routes from 'linkTo' in project data file
*/
routes: function () {
var routesArray = []
const projectData = require('./data/projects.json')
var projectGroups = projectData.projectGroups
for (var projectGroup in projectGroups) {
var projects = projectGroups[projectGroup].projects
for (var project in projects) {
routesArray.push('/work/projects/' + projects[project].slug + '/')
}
}
return routesArray
}
},
plugins: [
'~/plugins/vue-scrollto.js',
'~/plugins/common.js',
'~/plugins/vue-awesome.js',
{
src: '~/plugins/vue-affix.js',
ssr: false
},
{
src: '~/plugins/fonts.js',
ssr: false
},
{
src: '~/plugins/picturefill.js',
ssr: false
}
],
modules: [
['nuxt-sass-resources-loader', './assets/styles/imports.scss'],
['@nuxtjs/pwa']
],
/*
** Build configuration
*/
build: {
postcss: [],
/*
** Run ESLINT on save
*/
extend (config, ctx) {
/** List all shared variables files */
const sharedVariableFiles = [
path.resolve(__dirname, 'assets/styles/breakpoints.js')
]
/** Define the sass-vars-loader with options */
const sassVarsLoader = {
loader: '@epegzz/sass-vars-loader',
options: {
files: sharedVariableFiles
}
}
/** Run .scss files through sass-vars-loader before anything else */
const scssLoader = config.module.rules.find((loader) => loader.test.toString() === '/\\.scss$/')
scssLoader.use.splice(5, 0, sassVarsLoader)
/** Run .vue files' scss through sass-vars-loader before anything else */
const vueLoader = config.module.rules.find((loader) => loader.test.toString() === '/\\.vue$/')
vueLoader.options.loaders.scss.splice(5, 0, sassVarsLoader)
/** Remove default image rule */
const imageRule = config.module.rules.find(r => r.test.toString() === '/\\.(png|jpe?g|gif|svg)$/')
config.module.rules.splice(config.module.rules.indexOf(imageRule), 1)
/** Push new image rule */
config.module.rules.push({
test: /\.(png|jpe?g|gif|tiff|webp|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 1000,
name: 'img/[name].[hash:4].[ext]'
}
}
]
})
if (ctx.isServer) {
/** Dunno why but this allows vue-awesome icons to be rendered server-side */
config.externals = [
nodeExternals({
whitelist: [/\.(?!(?:js|json)$).{1,5}$/i, /^vue-awesome/, /es6-promise/]
})
]
}
if (ctx.isClient) {
/** Remove sourcemap from es6-promise on client */
config.module.rules.push({
test: /\.js$/,
include: /node_modules\/es6-promise/,
loader: 'strip-sourcemap-loader'
})
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
}