-
Notifications
You must be signed in to change notification settings - Fork 3
/
nuxt.config.js
145 lines (137 loc) · 3.86 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
import path from 'path'
import PurgecssPlugin from 'purgecss-webpack-plugin'
import glob from 'glob-all'
import dotenv from 'dotenv'
dotenv.config({ path: '.env' })
class TailwindExtractor {
static extract(content) {
return content.match(/[A-z0-9-:/]+/g) || []
}
}
export default {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: 'Django Nuxt SSR - To Do With Vue',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: "Django & Nuxt SSR" }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#9c6df4' },
// I'm not sure this is necessary
transition: {
name: 'page',
mode: 'out-in'
},
/*
** Global CSS
*/
css: [
'@assets/style/main.pcss'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/axios',
'@nuxtjs/pwa',
['nuxt-fontawesome', {
component: 'fa',
imports: [
// aggresive tree-shaking for production projects
{
set: '@fortawesome/free-brands-svg-icons',
icons: ['faGithub']
},
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['faHome', 'faQuestionCircle', 'faList', 'faWindowClose', 'faExclamationTriangle', 'faPlus']
}
]
}]
],
axios: {
proxy: true,
progress: true,
baseURL: process.env.PRODUCTION === "true" ? process.env.HEROKU_BACKEND_API_URL : process.env.LOCAL_API_URL,
baseBrowserURL: process.env.PRODUCTION === "true" ? process.env.HEROKU_BACKEND_API_URL : process.env.LOCAL_API_URL,
// can't figure out why yet but prefix is needed even when the two above are enabled
prefix: "api/"
},
proxy: {
// ** is important here, * probably means it won't go more than one level deep
'/api/**': { target: process.env.PRODUCTION === "true" ? process.env.HEROKU_BACKEND_API_URL : process.env.LOCAL_API_URL, pathRewrite: { '^/api': '' } }
},
env: {
BASE_WS: process.env.PRODUCTION === "true" ? process.env.REMOTE_BASE_WS : 'ws://localhost:8000/api/ping-consumer'
},
/*
** Build configuration
*/
build: {
// analyze: {
// analyzerMode: 'server',
// openAnalyzer: true
// },
extractCSS: true,
postcss: {
parser: 'postcss-scss',
// Add plugin names as key and arguments as value
plugins: {
'tailwindcss': path.resolve(__dirname, './tailwind.config.js'),
'postcss-nested': {}
}
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {
config.resolve.alias['@fortawesome/fontawesome-free-brands$'] = '@fortawesome/fontawesome-free-brands/shakable.es.js'
// Remove unused CSS using purgecss. See https://github.com/FullHuman/purgecss
// for more information about purgecss.
config.plugins.push(
new PurgecssPlugin({
// Specify the locations of any files you want to scan for class names.
paths: glob.sync([
path.join(__dirname, './pages/**/*.vue'),
path.join(__dirname, './layouts/**/*.vue'),
path.join(__dirname, './components/**/*.vue')
]),
extractors: [
{
extractor: TailwindExtractor,
// Specify the file extensions to include when scanning for
// class names.
extensions: ["html", "vue"]
}
],
whitelist: [
"html",
"body",
"ul",
"ol",
"pre",
"code",
"blockquote"
],
whitelistPatterns: [/\bhljs\S*/, /fa/] // also ignore font-awesome (find a better way)
})
)
}
}
}