| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import * as path from "path";
- const devPort = 3000;
- const serverPort = 4201;
- const env = {
- dev: {
- MODE: 'development',
- ENV_API: `http://127.0.0.1:${devPort}` //测试服务器地址
- },
- pro: {
- MODE: 'production',
- ENV_API: `http://127.0.0.1:${serverPort}` // 正式服务器地址
- }
- }
- function loadSvgConfig(config, ctx) {
- // 排除 nuxt 原配置的影响,Nuxt 默认有vue-loader,会处理svg,img等
- // 找到匹配.svg的规则,然后将存放svg文件的目录排除
- const svgRule = config.module.rules.find(rule => rule.test.test(".svg"));
- svgRule.exclude = [path.resolve(__dirname, "assets/icons/svg")];
- //添加loader规则
- config.module.rules.push({
- test: /\.svg$/, // 匹配.svg
- include: [path.resolve(__dirname, "assets/icons/svg")], // 将存放svg的目录加入到loader处理目录
- use: [
- { loader: "svg-sprite-loader", options: { symbolId: "icon-[name]" } }
- ]
- });
- }
- export default {
- // Global page headers (https://go.nuxtjs.dev/config-head)
- head: {
- title: '合方圆-合天地方圆',
- meta: [
- { charset: 'utf-8' },
- { name: 'viewport', content: 'width=device-width, initial-scale=1' },
- { hid: 'description', name: 'description', content: '' }
- ],
- link: [
- { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
- ]
- },
- css: [
- '@/assets/public.css',
- '@/assets/tailwindCom.css',
- ],
- // Auto import components (https://go.nuxtjs.dev/config-components)
- components: true,
- // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
- buildModules: [
- '@nuxtjs/tailwindcss'
- ],
- // Modules (https://go.nuxtjs.dev/config-modules)
- modules: [
- // https://go.nuxtjs.dev/axios
- '@nuxtjs/axios',
- // '@nuxtjs/style-resources',
- ],
- plugins: [
- "@plugins/svg-icon.js",
- // {src: '~/plugins/vue-pdf.js', ssr: false}
- ],
- // api中间件
- serverMiddleware: [
- '~/server/index.js'
- ],
- // styleResources: {
- // scss: [
- // '~/assets/_var.scss'
- // ]
- // },
- // Axios module configuration (https://go.nuxtjs.dev/config-axios)
- axios: {
- proxy: true
- },
- proxy: {
- },
- // Build Configuration (https://go.nuxtjs.dev/config-build)
- build: {
- extractCSS: true,
- extend(config, ctx) {
- loadSvgConfig(config,ctx);
- // 合并js文件
- // config.optimization.splitChunks = {
- // chunks: 'all',
- // minChunks: 1,
- // cacheGroups: {
- // vendor: {
- // test: /[\\/]node_modules[\\/]/,
- // name(module) {
- // // get the name. E.g. node_modules/packageName/not/this/part.js
- // // or node_modules/packageName
- // const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
- // // npm package names are URL-safe, but some servers don't like @ symbols
- // return `npm.${packageName.replace('@', '')}`;
- // }
- // }
- // }
- // }
- },
- },
- env : process.env.NODE_ENV === 'production' ? env.pro : env.dev,
- server: {
- // 根据环境变量判断当前运行环境 nuxt start 使用production环境
- port: process.env.NODE_ENV === 'production' ? serverPort : devPort, // default: 3000
- host: '0.0.0.0', // default: localhost
- },
- generate: {
- routes:
- [
- '/product/m2m',
- '/product/aiCam',
- '/product/sm',
- '/product/low',
- '/product/cam',
- '/product/item/m2m',
- '/product/item/aiCam',
- '/product/item/sm',
- '/product/item/low',
- '/product/item/cam',
- '/solution/sol',
- '/solution/acs',
- '/solution/epower',
- '/solution/item/sol',
- '/solution/item/acs',
- '/solution/item/epower',
- '/news/com',
- '/news/pa',
- '/news/in',
- '/news/item/com',
- '/news/item/pa',
- '/news/item/in',
- ]
- }
- }
|