-
Notifications
You must be signed in to change notification settings - Fork 66
/
vue.lib.js
111 lines (101 loc) · 3.02 KB
/
vue.lib.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
const WebpackPwaManifest = require('webpack-pwa-manifest');
const { execSync } = require('child_process');
const { defineConfig } = require('@vue/cli-service');
const path = require('path');
const pluginsConf = require('./plugins.json');
const PluginMaker = require('./src/building/plugin-maker');
const CONFIG_PATH = 'vue.lib.js';
const ENTRY_PATH = './src/frontend/bootstrap.js';
const EXEC_COMMAND = [
`VUE_CLI_SERVICE_CONFIG_PATH=$PWD/${CONFIG_PATH}`,
'vue-cli-service build',
`--target lib ${ENTRY_PATH}`
];
const plugins = [];
const entries = {};
!process.env.VUE_APP_DOCHUB_SMART_ANTS_SOURCE && (process.env.VUE_APP_DOCHUB_SMART_ANTS_SOURCE = '@assets/libs/smartants');
(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());
const config = defineConfig({
transpileDependencies: ['vueitfy'],
productionSourceMap: false,
publicPath: './',
css: {
sourceMap: false
},
configureWebpack: {
entry: entries,
plugins,
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
},
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
noEmit: false
}
}
}
]
},
{
test: /\.(ttf|otf|eot|woff|woff2)$/,
type: 'asset/resource',
generator: {
filename: './fonts/[name][ext]'
}
}
]
},
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(process.argv.length < 3) {
execSync(`${EXEC_COMMAND}`.replace(/,/g, ' '), {
stdio: 'inherit',
encoding: 'utf8'
});
execSync('chmod -R 777 ./dist');
execSync('mv ./dist/dochubcore.umd.min.js ./dist/dochub.js');
execSync('rm -rf ./dist/*umd* ./dist/*common* ./dist/*html*');
execSync('mkdir ./dist/backend');
execSync('cp -r ./src/backend ./dist/backend/src');
execSync('cp -r ./src/global ./dist/backend/global');
execSync('cp -r ./src/assets ./dist/backend/assets');
}
})();
module.exports = config;