-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvue.config.js
More file actions
executable file
·103 lines (99 loc) · 2.83 KB
/
vue.config.js
File metadata and controls
executable file
·103 lines (99 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = /\.(js|css|json|md|html|ico)(\?.*)?$/i;
const path = require('path');
const process = require('process');
const fs = require('fs');
const { execSync } = require('child_process');
const packageJson = require('./package.json');
// Generate build hash (first 8 characters of git commit hash)
let buildHash = '';
try {
buildHash = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim().substring(0, 8);
} catch (e) {
buildHash = 'unknown';
}
// Generate build date
const buildDate = new Date().toISOString().split('T')[0];
// Set environment variables
process.env.VUE_APP_VERSION = packageJson.version;
process.env.VUE_APP_BUILD_HASH = buildHash;
process.env.VUE_APP_BUILD_DATE = buildDate;
module.exports = {
productionSourceMap: false,
chainWebpack: (config) => {
config.plugins.delete('prefetch');
if (process.env.NODE_ENV === 'production') {
config.plugin('compressionPlugin').use(
new CompressionWebpackPlugin({
filename: '[path][base].br',
algorithm: 'brotliCompress',
test: productionGzipExtensions,
compressionOptions: {
level: 11,
},
}),
);
}
},
devServer: {
host: 'localhost',
hot: true,
port: 8000,
compress: true,
proxy: {
'/v1': {
// target: 'http://coursebench.org',
target: 'http://localhost:5000',
changeOrigin: true,
secure: false,
pathRewrite: {
// '^/v1': '' // 如果后端不需要/v1前缀,可以移除它
}
}
}
},
transpileDependencies: ['vuetify'],
configureWebpack: {
cache: {
type: 'filesystem',
},
resolve: {
alias: {
'@': path.join(__dirname, './src'),
},
},
externals: {
Config: JSON.stringify({
serverUrl: process.env.SERVER,
buildVersion: process.env.BUILD_VERSION,
buildMode: process.env.BUILD_MODE,
}),
Policy: JSON.stringify({
privacyPolicy: fs.readFileSync(
path.join(__dirname, './src/assets/privacy_policy.md'),
'utf8',
),
termsOfService: fs.readFileSync(
path.join(__dirname, './src/assets/terms_of_service.md'),
'utf8',
),
commentPolicy: fs.readFileSync(
path.join(__dirname, './src/assets/comment_policy.md'),
'utf8',
),
benchReviewerPolicy: fs.readFileSync(
path.join(__dirname, './src/assets/bench_reviewer.md'),
'utf8',
),
}),
},
module: {
rules: [
{
test: /\.md$/,
use: ['./src/plugins/markdown-loader'],
},
],
},
},
};