1.nuxt.config.js
const env = require('./env')
module.exports = {
env: {
imgUrl: env[process.env.MODE].imgUrl,
socketUrl: env[process.env.MODE].socketUrl,
ueditorConfig: {
toolbars: [[
'fullscreen', 'source', '|', 'undo', 'redo', '|',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
'directionalityltr', 'directionalityrtl', 'indent', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
'print', 'preview', 'searchreplace', 'drafts', 'help'
]],
autoHeightEnabled: false,
initialFrameHeight: 400,
initialFrameWidth: '99%',
UEDITOR_HOME_URL: "/UEditor/",
serverUrl: env[process.env.MODE].externalApiUrl + "/ueditor/config"
}
},
head: {
title: 'xxx',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'renderer', content: 'webkit' },
{ name: 'force-rendering', content: 'webkit' },
{ 'http-equiv': 'X-UA-Compatible', content: 'IE=Edge,chrome=1' },
{ hid: 'description', name: 'description', content: 'xxx' },
{
name: 'xxx',
content:
'xxx'
}
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/web_icon.ico' },
]
},
router: {
scrollBehavior(to, from, savedPosition) {
if (to && from) {
return { x: 0, y: 0 }
}
},
parseQuery: (querystring) => {
const QS = require('qs')
return QS.parse(querystring)
},
stringifyQuery: (paramObj) => {
const QS = require('qs')
return QS.stringify(paramObj, { addQueryPrefix: true })
}
},
loading: { color: '#3B8070' },
css: [
'~/assets/style/theme/index.css',
'~/assets/style/font/iconfont.css',
'~/assets/style/index.styl',
],
plugins: [
{ src: '~/plugins/ElementUI', ssr: true },
{ src: '~/plugins/common.js' },
{ src: '~/plugins/jumpLink.js' },
{ src: '~/plugins/store.js' },
{ src: '~/plugins/vuex-localStorage.js', ssr: false },
{ src: '~/plugins/vuex-cookie.js' },
{ src: '~/plugins/route.js', ssr: false },
{ src: '~/plugins/axios.js' },
{ src: '~/plugins/axios-api-plugin.js' },
{ src: '~/plugins/rules.js' },
{ src: '~/plugins/socket', ssr: false },
{ src: '~/assets/style/font/iconfont.js', ssr: false },
{ src: '~/plugins/icon.js' },
{ src: "~/plugins/vue-lazyload.js", ssr: false },
],
modules: [
'@nuxtjs/style-resources',
'@nuxtjs/axios'
],
axios: {
proxy: true,
prefix: '/api',
credentials: true,
baseURL: env[process.env.MODE].apiUrl
},
proxy: {
'/api': {
target: env[process.env.MODE].apiUrl,
changeOrigin: true,
pathRewrite: {
'^/api': ''
},
},
},
styleResources: {
stylus: '~/assets/style/public.styl'
},
build: {
extend(config, ctx) {
if (ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
},
vendor: ['element-ui', 'axios', 'vue-lazyload'],
babel: {
presets: function ({ isServer }, [preset, options]) {
const r = [
[
preset, {
buildTarget: isServer ? 'server' : 'client',
...options
}]
];
r[0][1].targets = {
"browsers": ["> 1%", "last 2 versions"],
ie: 11
};
r[0][1].polyfills = [
'es6.array.iterator',
'es6.promise',
'es6.object.assign',
'es6.symbol',
'es6.array.find',
'es6.array.from',
'es7.promise.finally',
'es7.object.entries',
];
return r;
},
plugins: [
['@babel/plugin-transform-runtime']
]
}
}
}