-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnuxt.config.js
140 lines (135 loc) · 4.71 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
const pkg = require('./package')
// resolve定义一个绝对路径获取函数
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: 'OASIS SCAN | Oasis Blockchain Explorer',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'OASIS SCAN provides an easy to use and popular block explorer, powerful data and advanced analytics. allows you to explore and search the OASIS blockchain for Entity, Block, Block hash, Txn hash, validator info. ' }
],
script: [
{ src: 'https://www.googletagmanager.com/gtag/js?id=UA-6150405-8', body: true, async: true },
{
innerHTML: `console.log(1111);window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-6150405-8');`,
type: 'text/javascript',
charset: 'utf-8',
body: true
}
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/logo_favicon.png' }],
__dangerouslyDisableSanitizers: ['script']
},
router: {
middleware: ['config', 'i18n']
},
/*
** Customize the progress-bar color
*/
loading: { color: '#1849a9' },
/*
** Global CSS
*/
css: ['iview/dist/styles/iview.css', '~/assets/css/main.css'],
/*
** Global SCSS
*/
styleResources: {
scss: ['~assets/css/common.scss', '~assets/css/color.scss']
},
/*
** Plugins to load before mounting the App
*/
plugins: ['~/plugins/axios.js', '@/plugins/iview', '~/plugins/i18n.js', '~/plugins/my-mixin.js', { src: '~plugins/highchart.js' }, '~/plugins/clipboard.js', '~/plugins/toast.js', '~/plugins/filters.js', '~/plugins/svg-icon.js', { src: '~/plugins/QRCode.js', ssr: false }],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/pwa',
'@nuxtjs/style-resources'
],
/*
** Axios module configuration
*/
axios: {
// See https://github.com/nuxt-community/axios-module#options
// baseURL: 'http://172.18.11.63:3000',
proxyHeaders: false,
// retry: { retries: 3 }
credentials: false,
proxy: true
},
// proxy: [
// 'https://api.oasisscan.com/v2/testnet/',
// 'https://api.oasisscan.com/v2/mainnet/',
// 'https://api.oasisscan.com/testnet/',
// 'https://api.oasisscan.com/mainnet/',
// ],
proxy: {
'/v2/testnet/': { target: 'http://api.internal.oasisscan.com:9191', pathRewrite: { '^/v2/testnet/': '' } },
'/v2/mainnet/': { target: 'http://api.internal.oasisscan.com:8191', pathRewrite: { '^/v2/mainnet/': '' } },
'/testnet/': { target: 'http://api-internal-v1.oasisscan.com:9181', pathRewrite: { '^/testnet/': '' } },
'/mainnet/': { target: 'http://api-internal-v1.oasisscan.com:8181', pathRewrite: { '^/mainnet/': '' } }
},
/*
** Build configuration
*/
build: {
postcss: {
plugins: {
'postcss-px-to-viewport': {
unitToConvert: 'md',
viewportWidth: 750, // (Number) The width of the viewport.
viewportHeight: 1334, // (Number) The height of the viewport.
unitPrecision: 6, // (Number) The decimal numbers to allow the vw units to grow t
viewportUnit: 'vw', // (String) Expected units.
selectorBlackList: ['.ignore', '.hairlines'], // (Array) The selectors to ignore and leave as px.
minPixelValue: 1, // (Number) Set the minimum pixel value to replace.
mediaQuery: true // (Boolean) Allow px to be converted in media queries.
}
// 'cssnano': {
// preset: 'advanced',
// autoprefixer: false,
// 'postcss-zindex': false
// }
}
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
// loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
// 排除 nuxt 原配置的影响,Nuxt 默认有vue-loader,会处理svg,img等
// 找到匹配.svg的规则,然后将存放svg文件的目录排除
const svgRule = config.module.rules.find(rule => rule.test.test('.svg'))
svgRule.exclude = [resolve('./assets/svg')]
// 添加loader规则
config.module.rules.push({
test: /\.svg$/, // 匹配.svg
include: [resolve('./assets/svg')], // 将存放svg的目录加入到loader处理目录
use: [{ loader: 'svg-sprite-loader', options: { symbolId: 'icon-[name]' } }]
})
}
}
}