lightlimx-website/nuxt.config.js

138 lines
3.8 KiB
JavaScript
Raw Normal View History

2024-07-10 18:16:12 +08:00
import redirectSSL from "redirect-ssl";
import serveStatic from "serve-static";
import { resolve } from "path";
const baseUrl = process.env.BASE_URL || "https://api.lightlimx.live/api";
2024-07-10 14:57:22 +08:00
export default {
2024-07-10 18:16:12 +08:00
ssr: false,
loading: "~/components/Loading/index.vue",
2024-07-10 14:57:22 +08:00
serverMiddleware: [
// redirectSSL.create({
// enabled: process.env.NODE_ENV === 'production'
// }),
2024-07-10 18:16:12 +08:00
{ path: "/static", handler: serveStatic(__dirname + "/static") },
2024-07-10 14:57:22 +08:00
],
2024-07-10 18:16:12 +08:00
telemetry: false,
2024-07-10 14:57:22 +08:00
publicRuntimeConfig: {
baseURL: baseUrl,
axios: {
2024-07-10 18:16:12 +08:00
baseURL: baseUrl,
},
2024-07-10 14:57:22 +08:00
},
env: {
2024-07-10 18:16:12 +08:00
baseUrl: process.env.BASE_URL || "http://localhost:3000",
apiUrl: "/api",
2024-07-10 14:57:22 +08:00
},
alias: {
2024-07-10 18:16:12 +08:00
"@": resolve(__dirname),
"~": resolve(__dirname),
style: resolve(__dirname, "./assets/style"),
images: resolve(__dirname, "./assets/images"),
data: resolve(__dirname, "./assets/data"),
2024-07-10 14:57:22 +08:00
},
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
2024-07-10 18:16:12 +08:00
title: "LightLimX",
2024-07-10 14:57:22 +08:00
htmlAttrs: {
2024-07-10 18:16:12 +08:00
lang: "en",
2024-07-10 14:57:22 +08:00
},
bodyAttrs: {
2024-07-10 18:16:12 +08:00
class: "h5-scroll-bar",
2024-07-10 14:57:22 +08:00
},
meta: [
2024-07-10 18:16:12 +08:00
{ charset: "utf-8" },
2024-07-10 14:57:22 +08:00
//width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no
2024-07-10 18:16:12 +08:00
{
name: "viewport",
content:
"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui,viewport-fit=cover",
},
{ hid: "description", name: "description", content: "" },
{ name: "format-detection", content: "telephone=no" },
2024-07-10 14:57:22 +08:00
],
2024-07-10 18:16:12 +08:00
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.png" }],
2024-07-10 14:57:22 +08:00
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
2024-07-10 18:16:12 +08:00
"~/assets/style/reset.less",
"~/assets/style/animate.css",
"vant/lib/index.css",
2024-07-10 14:57:22 +08:00
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
2024-07-10 18:16:12 +08:00
{ src: "~/plugins/remJs.js", mode: "client" },
"@/plugins/vant",
"~/plugins/axios.js",
"~/plugins/vueTooltip.js",
2024-07-10 14:57:22 +08:00
// { src: '~/plugins/vueAnimate.js', mode: 'client' },
2024-07-10 18:16:12 +08:00
{ src: "~/plugins/vueClipboard.js", mode: "client" },
{ src: "~/plugins/lottieWeb.js", mode: "client" },
{ src: "~/plugins/svgIcon.js", mode: "client" },
{ src: "~/plugins/wow.js", mode: "client" },
{ src: "~/plugins/element.js", mode: "client" },
2024-07-10 14:57:22 +08:00
],
router: {
// base: '/assets/',
2024-07-10 18:16:12 +08:00
middleware: ["authenticated"],
2024-07-10 14:57:22 +08:00
},
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
2024-07-10 18:16:12 +08:00
buildModules: [],
2024-07-10 14:57:22 +08:00
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
2024-07-10 18:16:12 +08:00
[
"nuxt-svg-sprite-loader",
{
symbolId: "icon-[name]",
},
],
"@nuxtjs/axios",
2024-07-10 14:57:22 +08:00
],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
2024-07-10 18:16:12 +08:00
transpile: ["vue-tooltip"],
2024-07-10 14:57:22 +08:00
extractCSS: {
// allChunks: true,
2024-07-10 18:16:12 +08:00
filename: "[name].css",
chunkFilename: "[id].css",
ignoreOrder: true,
2024-07-10 14:57:22 +08:00
},
babel: {
plugins: [
[
2024-07-10 18:16:12 +08:00
"component",
2024-07-10 14:57:22 +08:00
{
2024-07-10 18:16:12 +08:00
libraryName: "element-ui",
2024-07-10 14:57:22 +08:00
// 'style': false // 不引入对应的css文件
2024-07-10 18:16:12 +08:00
styleLibraryName: "theme-chalk",
},
],
],
2024-07-10 14:57:22 +08:00
},
2024-07-10 18:16:12 +08:00
extend(config, { isDev, isClient }) {
2024-07-10 14:57:22 +08:00
if (isClient) {
// 排除 nuxt 原配置的影响,Nuxt 默认有vue-loader,会处理svg,img等
// 找到匹配.svg的规则,然后将存放svg文件的目录排除
2024-07-10 18:16:12 +08:00
const svgRule = config.module.rules.find((rule) =>
rule.test.test(".svg")
);
svgRule.exclude = [resolve("assets/svg")];
2024-07-10 14:57:22 +08:00
// 添加loader规则
}
config.module.rules.push({
test: /\.(mpg|ts|pm4)$/i,
2024-07-10 18:16:12 +08:00
loader: "url-loader",
2024-07-10 14:57:22 +08:00
options: {
2024-07-10 18:16:12 +08:00
outputPath: "/static/video/",
publicPath: "/static/video/",
},
});
},
},
};