-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
167 lines (159 loc) · 5.38 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import colors from 'vuetify/es5/util/colors'
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
// const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
const GitRevisionPlugin = require('git-revision-webpack-plugin')
const git_revision_plugin = new GitRevisionPlugin()
const webpack = require('webpack')
const env = require('dotenv').config({ path: '.env.' + process.env.BASE })
const base = process.env.BASE === 'prod' ? '/web3/' : '/dapp/web3/'
export default {
// Target (https://go.nuxtjs.dev/config-target)
server: {
host: '0.0.0.0',
port: 39300 // default: 3000
},
target: 'server',
env: env.parsed,
// Global page headers (https://go.nuxtjs.dev/config-head)
head: {
// titleTemplate: '%s - Yswap',
titleTemplate: '%s',
title: 'Web3',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/png', href: base + 'yswap@2x.png' },
{ rel: 'stylesheet', type: 'text/css', href: 'https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css' }
]
// script: [
// { src: base + 'rem/flexible.js', type: 'text/javascript', charset: 'utf-8' }
// ]
},
router: {
middleware: ['route'],
base: base
},
// Global CSS (https://go.nuxtjs.dev/config-css)
css: [
],
styleResources: {
scss: [
'./assets/css/fun.scss',
'./assets/css/resetVuetify.scss',
'./assets/css/color.scss',
'./assets/css/font.scss',
'./assets/css/space.scss',
'./assets/css/common.scss',
'./assets/css/main.scss'
]
},
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [
'~/plugins/index.js'
// todo vuetify按需加载
// {
// src: '~/plugins/vuetify.js',
// ssr: true // 关闭ssr
// }
],
// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
// https://go.nuxtjs.dev/eslint
'@nuxtjs/eslint-module',
// https://go.nuxtjs.dev/vuetify
'@nuxtjs/vuetify'
],
// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
'@nuxtjs/axios',
'@nuxtjs/dotenv',
'@nuxtjs/style-resources'
],
axios: {
// proxy:true // 代理
},
proxy: {
// "/api/":"http://localhost:3001/" // key(路由前缀):value(代理地址)
},
// Vuetify module configuration (https://go.nuxtjs.dev/config-vuetify)
vuetify: {
customVariables: ['~/assets/variables.scss'],
theme: {
light: true,
themes: {
light: {
primary: '#01598d',
secondary: colors.grey.darken1,
accent: colors.shades.black,
error: colors.red.accent3
}
}
}
},
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
// analyze: true,
transpile: ['vuetify/lib'],
plugins: [
new webpack.DefinePlugin({
'process.COMMITHASH': JSON.stringify(git_revision_plugin.commithash())
})
// todo VuetifyLoader 作为vuetify的按需加载使用,解决vendors包太大的问题,目前使用还存在问题,https://github.com/vuetifyjs/vuetify-loader/issues/161 此bug还未解决
// new VuetifyLoaderPlugin({
// match (originalTag, { kebabTag, camelTag, path, component }) {
// if (kebabTag.startsWith('core-')) {
// return [
// camelTag,
// `import ${camelTag} from '@/components/core/${camelTag.substring(4)}.vue'`
// ]
// }
// }
// })
],
/**
* todo: nuxt 升级到3.0版本以上的时候需要改为对象的形式展示,目前用的是nuxt2.14.6暂时用数组,构建的时候会有警告
* 2.0版本切换object rem 不生效
* Using an Array as build.postcss will be deprecated in Nuxt 3. Please switch to the object declaration
*/
// postcss: [
// require('postcss-px2rem')({
// remUnit: 75
// })
// ],
/*
** You can extend webpack config here
*/
// 使用splitChunks将chunks明确切分开来。
optimization: {
splitChunks: {
minSize: 10000,
maxSize: 250000
}
},
extend (config, { isDev, isClient }) {
if (isClient && !isDev) {
// config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
config.optimization.minimizer[0].options.terserOptions.compress = {
warnings: false,
drop_debugger: true, // debugger
drop_console: false, // console
pure_funcs: ['console.log'] // 移除console.log
}
config.plugins.unshift(new LodashModuleReplacementPlugin())
config.module.rules[2].use[0].options.plugins = ['lodash']
// config.plugins.push(new VuetifyLoaderPlugin())
// config.optimization.splitChunks.cacheGroups.commons = {
// test: /node_modules[\\/](vue|vue-loader|vue-router|vuex|vue-meta|core-js|@babel\/runtime|axios|webpack|setimmediate|timers-browserify|process|regenerator-runtime|cookie|js-cookie|is-buffer|dotprop|nuxt\.js)[\\/]/,
// chunks: 'all',
// priority: 10,
// name: true
// }
}
}
}
}