forked from nimiq/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue.config.js
More file actions
128 lines (120 loc) · 4.34 KB
/
vue.config.js
File metadata and controls
128 lines (120 loc) · 4.34 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
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
const CopyWebpackPlugin = require('copy-webpack-plugin');
const WriteFileWebpackPlugin = require('write-file-webpack-plugin');
const path = require('path');
const fs = require('fs');
const browserWarning = fs.readFileSync(__dirname + '/node_modules/@nimiq/browser-warning/dist/browser-warning.html.template');
const buildName = process.env.build
? process.env.build
: process.env.NODE_ENV === 'production'
? 'testnet'
: 'local';
const domain = buildName === 'mainnet'
? 'https://hub.nimiq.com'
: buildName === 'testnet'
? 'https://hub.nimiq-testnet.com'
: 'http://localhost:8080';
console.log('Building for:', buildName);
const configureWebpack = {
plugins: [
new CopyWebpackPlugin([
{ from: 'node_modules/@nimiq/vue-components/dist/img', to: 'img' },
{ from: 'node_modules/@nimiq/browser-warning/dist', to: './' },
]),
new WriteFileWebpackPlugin()
],
// Resolve config for yarn build
resolve: {
alias: {
config: path.join(__dirname, `src/config/config.${buildName}.ts`)
}
},
// Fix sourcemaps (https://www.mistergoodcat.com/post/the-joy-that-is-source-maps-with-vuejs-and-typescript)
devtool: 'eval-source-map',
output: {
devtoolModuleFilenameTemplate: info => {
var $filename = 'sources://' + info.resourcePath;
if (info.resourcePath.match(/\.vue$/) && !info.query.match(/type=script/)) {
$filename = 'webpack-generated:///' + info.resourcePath + '?' + info.hash;
}
return $filename;
},
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
},
};
const pages = {
index: {
// entry for the page
entry: 'src/main.ts',
// the source template
template: 'public/index.html',
// insert browser warning html templates
browserWarning,
domain,
// output as dist/index.html
filename: 'index.html',
// chunks to include on this page, by default includes
// extracted common chunks and vendor chunks.
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
iframe: {
// entry for the page
entry: 'src/iframe.ts',
// the source template
template: 'public/iframe.html',
// output as dist/iframe.html
filename: 'iframe.html',
// chunks to include on this page, by default includes
// extracted common chunks and vendor chunks.
chunks: ['chunk-vendors', 'chunk-common', 'iframe']
},
'cashlink-app': {
// entry for the page
entry: 'src/cashlink.ts',
// the source template
template: 'public/cashlink.html',
// insert browser warning html templates
browserWarning,
domain,
// output as dist/cashlink/index.html
filename: 'cashlink/index.html',
// chunks to include on this page, by default includes
// extracted common chunks and vendor chunks.
chunks: ['chunk-vendors', 'chunk-common', 'cashlink-app']
},
};
if (buildName === 'local' || buildName === 'testnet') {
pages.demos = {
// entry for the page
entry: 'demos/Demo.ts',
// the source template
template: 'demos/index.html',
// output as dist/index.html
filename: 'demos.html',
// chunks to include on this page, by default includes
// extracted common chunks and vendor chunks.
chunks: ['chunk-vendors', 'chunk-common', 'demos']
};
}
module.exports = {
pages,
configureWebpack,
chainWebpack: config => {
// Do not put prefetch/preload links into the landing pages
config.plugins.delete('prefetch-index');
config.plugins.delete('preload-index');
config.plugins.delete('prefetch-iframe');
config.plugins.delete('preload-iframe');
config.plugins.delete('prefetch-cashlink-app');
config.plugins.delete('preload-cashlink-app');
config.plugins.delete('prefetch-demos');
config.plugins.delete('preload-demos');
config.module
.rule('ts')
.use('ts-loader')
.loader('ts-loader')
.tap(options => {
options.configFile = `tsconfig.${buildName}.json`
return options
});
}
}