irc_web/.svn/pristine/2c/2cfbf626e60a76f0126bd334ba4...

124 lines
3.6 KiB
Plaintext

'use strict'
// eslint-disable-next-line no-undef
const path = require('path')
// eslint-disable-next-line no-undef
const defaultSettings = require('./src/settings.js')
const CopyPlugin = require('copy-webpack-plugin')
function resolve(dir) {
// eslint-disable-next-line no-undef
return path.join(__dirname, dir)
}
const name = defaultSettings.title || 'IRaCIS' // page title
// eslint-disable-next-line no-undef
module.exports = {
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: {
'/api': {
// target: 'http://47.90.210.20:8000', //美国服务器
// 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': ''
}
}
}
},
configureWebpack: {
name: name,
output: {
filename: `static/js/[name].[hash].js`,
chunkFilename: `static/js/[name].[hash].js`
},
plugins: [
new CopyPlugin([
{ from: './node_modules/cornerstone-wado-image-loader/dist/cornerstoneWADOImageLoaderWebWorker.min.js', to: 'webWorker.js' },
{ from: './node_modules/cornerstone-wado-image-loader/dist/cornerstoneWADOImageLoader.min.js', to: 'dicomCodecs.js' },
{ 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: ['.*']
}
])
// new OfflinePlugin({})
],
performance: {
hints: 'warning',
// 入口起点的最大体积
maxEntrypointSize: 5000000000,
// 生成文件的最大体积
maxAssetSize: 3000000000,
// 只给出js的性能提示
assetFilter: function(assetFileName) {
return assetFileName.endsWith('.js')
}
},
resolve: {
alias: {
'@': resolve('src'),
'modules': resolve('node_modules'),
'utils': resolve('src/utils')
}
}
},
chainWebpack(config) {
// config.plugins.delete('preload') // TODO: need test
// config.plugins.delete('prefetch') // TODO: need test
// set svg-sprite-loader
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()
}
}