-
Notifications
You must be signed in to change notification settings - Fork 66
/
vue.config.js
169 lines (157 loc) · 4.83 KB
/
vue.config.js
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
const WebpackPwaManifest = require('webpack-pwa-manifest');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('@effortlessmotion/html-webpack-inline-source-plugin');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const pluginsConf = require('./plugins.json');
const PluginMaker = require('./src/building/plugin-maker');
const path = require('path');
const package = require('./package.json');
const plugins = [];
const entries = {
app: './src/frontend/main.js'
};
// Указывается где лежит движок SmartAnts
!process.env.VUE_APP_DOCHUB_SMART_ANTS_SOURCE && (process.env.VUE_APP_DOCHUB_SMART_ANTS_SOURCE = '@assets/libs/smartants');
// Определяем версии API плагинов, которые поддерживаются в Enterprise режиме
const ideaAPIAvailable = process.env.VUE_APP_DOCHUB_IDE_IDEA_API || package.ide?.idea?.api || [];
process.env.VUE_APP_DOCHUB_IDE_IDEA_API = Array.isArray(ideaAPIAvailable) ? ideaAPIAvailable : ideaAPIAvailable.toString().split(',');
const vscodeAPIAvailable = process.env.VUE_APP_DOCHUB_IDE_VSCODE_API || package.ide?.vscode?.api || [];
process.env.VUE_APP_DOCHUB_IDE_IDEA_API = Array.isArray(vscodeAPIAvailable) ? vscodeAPIAvailable : vscodeAPIAvailable.toString().split(',');
// Собираем встраиваемые плагины
//if (process.env.VUE_APP_DOCHUB_MODE === 'production') {
(pluginsConf?.inbuilt || []).map((item) => {
const config = require(`./${item}/package.json`);
entries[`plugins/${item}`] = `./${item}/${config.main || 'index.js'}`;
});
//}
// Добавляем в манифест внешние плагины
const manifest = {
name: 'DocHub',
short_name: 'DocHub',
description: 'Architecture as a code',
background_color: '#ffffff',
crossorigin: 'use-credentials',
plugins: pluginsConf?.external,
filename: 'manifest.json'
};
plugins.push(new WebpackPwaManifest(manifest));
// Добавляем собственный плагин-мейкер
plugins.push(new PluginMaker());
if (process.env.VUE_APP_DOCHUB_MODE === 'plugin') {
plugins.push(new HtmlWebpackPlugin({
filename: 'plugin.html',
template: 'src/ide/plugin.html',
inlineSource: '.(woff(2)?|ttf|eot|svg|js|css|map)$',
inject: true
/* ,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
minifyCSS: true,
minifyJS: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
} */
}));
plugins.push(new HtmlWebpackInlineSourcePlugin());
} else {
// plugins.push(new BundleAnalyzerPlugin());
}
// Дефолтная конфигурация dev-сервера
let config = {
runtimeCompiler: true,
devServer: {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
},
/*
allowedHosts: [
'localhost'
],
*/
client: { overlay: false },
hot: process.env.VUE_APP_DOCHUB_HOTRELOAD === 'off' ? false : true
},
transpileDependencies: ['vueitfy'],
chainWebpack: (config) => {
config.module.rules.delete("svg");
},
configureWebpack: {
cache: (process.env.VUE_APP_DOCHUB_BUILDING_CACHE || 'memory').toLowerCase() === 'filesystem'
? {
type: 'filesystem',
compression: 'gzip',
allowCollectingMemory: true
}
: {
type: 'memory'
},
experiments: {
outputModule: true
},
optimization: {
splitChunks: false,
runtimeChunk: 'single'
},
entry: { ...entries },
plugins,
module: {
rules: [
{
test: /\.svg$/,
loader: 'vue-svg-loader'
},
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
},
{
test: /\.([cm]?ts|tsx)$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
noEmit: false
}
}
}
]
}
]
},
output: {
filename: '[name].js'
},
resolve: {
alias: {
'@front': path.resolve(__dirname, './src/frontend'),
'@assets': path.resolve(__dirname, './src/assets'),
'@back': path.resolve(__dirname, './src/backend'),
'@idea': path.resolve(__dirname, './src/ide/idea'),
'@vscode': path.resolve(__dirname, './src/ide/vscode'),
'@ide': path.resolve(__dirname, './src/ide'),
'@global': path.resolve(__dirname, './src/global'),
'@': path.resolve(__dirname, './')
},
extensions: ['.ts', '.js']
}
}
};
// Подключает сертификаты, если они обнаружены
/*
if(fs.lstatSync(__dirname + '/certs').isDirectory()) {
config.devServer = {
http2: true,
https: {
key: fs.readFileSync(__dirname + '/certs/server.key'),
cert: fs.readFileSync(__dirname + '/certs/server.cert')
}
}
}
*/
module.exports = config;