irc_web/vue.config.js

227 lines
9.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

'use strict'
const path = require('path')
// eslint-disable-next-line no-undef
const defaultSettings = require('./src/settings.js')
const CopyPlugin = require('copy-webpack-plugin')
const WebpackAliyunOss = require('webpack-aliyun-oss')
const moment = require('moment')
var distDate = moment(new Date()).format('YYYY-MM-DD')
function resolve(dir) {
// eslint-disable-next-line no-undef
return path.join(__dirname, dir)
}
const name = process.env.NODE_ENV === 'usa' ? 'LiLi' : defaultSettings.title || 'IRCIS' // page title
// eslint-disable-next-line no-undef
module.exports = {
// lintOnSave: false,
transpileDependencies: ['@cornerstonejs', 'minio', '@aws-sdk', '@smithy'],
publicPath: process.env.NODE_ENV === 'development' || process.env.VUE_APP_OSS_CONFIG_BUCKET === 'zyypacs-usa' ? process.env.VUE_APP_BASE_PATH : `${process.env.VUE_FILE_PATH}${process.env.VUE_APP_OSS_PATH}${distDate}/`,
// publicPath: '/',
outputDir: 'dist',
assetsDir: 'static',
productionSourceMap: false,
devServer: {
port: '8080',
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
},
// open: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
'/UploadHub': {
// target: 'http://44.218.11.19:30000', //美国服务器
// target: 'http://123.56.181.144:8001', // 国内生产环境
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
// target: 'http://123.56.94.154:8079', // 国内测试环境2
target: 'http://123.56.94.154:7000', // 国内测试环境2
// target: 'http://123.56.181.144:7000',
changeOrigin: true,
secure: false,
pathRewrite: {
'^/api': ''
}
},
'/IRaCISData': {
target: 'http://123.56.94.154:8060/', // 国内测试环境2
// target: 'http://123.56.181.144:7000',
changeOrigin: true,
pathRewrite: {
}
},
'/api': {
// target: 'http://44.218.11.19:30000', //美国服务器
// target: 'http://123.56.181.144:8001', // 国内生产环境
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
// target: 'http://123.56.94.154:8079', // 国内测试环境2
// target: 'http://123.56.94.154:7000', // 国内测试环境2
// target: 'http://123.56.94.154:30668',
target: 'http://106.14.89.110:30000',
//target: 'http://localhost:3305', // 后端测试环境
// target: 'http://47.117.164.182:7010', // uat
// target: 'http://123.56.181.144:7000',
changeOrigin: true,
secure: false,
pathRewrite: {
'^/api': ''
}
}
}
},
configureWebpack: {
name: name,
output: {
filename: `static/js/[name].[hash].js`,
chunkFilename: `static/js/[name].[hash].js`
},
plugins: [
new CopyPlugin([
// { from: './node_modules/@cornerstonejs/codec-charls/dist/charlsjs.js', to: 'charlsjs.js' },
// { from: './node_modules/@cornerstonejs/codec-charls/dist/charlsjs.js.mem', to: './static/js/charlsjs.js.mem' },
// { from: './node_modules/@cornerstonejs/codec-charls/dist/charlswasm.js', to: './static/js/charlswasm.js' },
// { from: './node_modules/@cornerstonejs/codec-charls/dist/charlswasm.wasm', to: './static/js/charlswasm.wasm' },
// { from: './node_modules/@ffmpeg/core/dist/ffmpeg-core.js', to: 'ffmpeg-core.js' },
// { from: './node_modules/@ffmpeg/core/dist/ffmpeg-core.wasm', to: 'ffmpeg-core.wasm' },
// { from: './node_modules/@ffmpeg/core/dist/ffmpeg-core.worker.js', to: 'ffmpeg-core.worker.js' },
{
from: path.resolve(__dirname, './static'),
to: path.resolve(__dirname, './dist/static'),
ignore: ['.*']
}
]),
process.env.NODE_ENV === 'development' || process.env.VUE_APP_OSS_CONFIG_BUCKET === 'zyypacs-usa' ? function () { }
: new WebpackAliyunOss({
from: ['./dist/**'],
dist: process.env.VUE_APP_OSS_PATH + distDate,
region: process.env.OSS_REGION,
accessKeyId: process.env.OSS_ACCESS_KEY_ID,
accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
bucket: process.env.OSS_BUCKET,
overwrite: true,
setOssPath: filePath => {
const index = filePath.lastIndexOf('dist')
const Path = filePath.substring(index + 4, filePath.length)
return Path.replace(/\\/g, '/')
},
setHeaders: filePath => {
return {
'Cache-Control': 'max-age=31536000'
}
}
})
// new OfflinePlugin({})
],
performance: {
hints: 'warning',
// 入口起点的最大体积
maxEntrypointSize: 5000000000,
// 生成文件的最大体积
maxAssetSize: 3000000000,
// 只给出js的性能提示
assetFilter: function (assetFileName) {
return assetFileName.endsWith('.js')
}
},
resolve: {
alias: {
// src/@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js
'@': resolve('src'),
'modules': resolve('node_modules'),
'utils': resolve('src/utils')
// '@cornerstonejs/dicom-image-loader': 'src/@cornerstonejs/dicom-image-loader',
// '@cornerstonejs/calculate-suv': 'src/@cornerstonejs/calculate-suv',
// '@cornerstonejs/core': 'src/@cornerstonejs/core',
// '@cornerstonejs/streaming-image-volume-loader': 'src/@cornerstonejs/streaming-image-volume-loader',
// '@cornerstonejs/tools': 'src/@cornerstonejs/tools',
// '@cornerstonejs/dicom-codec': 'src/@cornerstonejs/dicom-codec',
// '@cornerstonejs/codec-charls': 'src/@cornerstonejs/codec-charls'
// '@cornerstonejs/dicom-image-loader': resolve('src/@cornerstonejs/dicom-image-loader'),
// '@cornerstonejs/calculate-suv': resolve('src/@cornerstonejs/calculate-suv'),
// '@cornerstonejs/core': resolve('src/@cornerstonejs/core'),
// '@cornerstonejs/streaming-image-volume-loader': resolve('src/@cornerstonejs/streaming-image-volume-loader'),
// '@cornerstonejs/tools': resolve('src/@cornerstonejs/tools'),
// '@cornerstonejs/dicom-codec': resolve('src/@cornerstonejs/dicom-codec'),
// '@cornerstonejs/codec-charls': resolve('src/@cornerstonejs/codec-charls')
// 'cornerstone-wado-image-loader': resolve('src/@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js')
}
}
},
chainWebpack(config) {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// set svg-sprite-loader
config.optimization.splitChunks({
chunks: "initial", //async异步代码分割 initial同步代码分割 all同步异步分割都开启
minSize: 30000, //字节 引入的文件大于30kb才进行分割
maxSize: 5000000, //50kb尝试将大于50kb的文件拆分成n个50kb的文件
minChunks: 1, //模块至少使用次数
maxAsyncRequests: 30, //同时加载的模块数量最多是5个只分割出同时引入的前5个文件
maxInitialRequests: 30, //首页加载的时候引入的文件最多3个
automaticNameDelimiter: '_', //缓存组和生成文件名称之间的连接符
name: true, //缓存组里面的filename生效覆盖默认命名
cacheGroups: { //缓存组,将所有加载模块放在缓存里面一起分割打包
vendors: { //自定义打包模块
test: /[\\/]node_modules[\\/]/,
priority: -10, //优先级,先打包到哪个组里面,值越大,优先级越高
filename: 'vendors.js',
},
default: { //默认打包模块
priority: -20,
reuseExistingChunk: true, //模块嵌套引入时,判断是否复用已经被打包的模块
filename: 'common.js'
}
}
})
config.module
.rule('svg')
.exclude.add(resolve('src/icons'))
.add(resolve('src/assets/icons'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/icons'))
.add(resolve('src/assets/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
.end()
// set preserveWhitespace
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
.end()
// config.module
// .rule('js')
// .test(/\.js$/)
// .exclude.add(resolve('node_modules'))
// .add(resolve('src'))
// .end()
// .use('babel-loader')
// .loader('babel-loader')
// .options({
// presets: ['@babel/preset-env']
// })
// .end()
}
}