-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
123 lines (113 loc) · 3.96 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
const CopyPlugin = require('copy-webpack-plugin');
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const path = require('path');
const inProduction = process.env.NODE_ENV === 'production';
const usesSentry = process.env.SENTRY_AUTH_TOKEN
&& process.env.SENTRY_PROJECT && process.env.SENTRY_ORG;
if (inProduction && !usesSentry) {
console.warn('For better error handing please configure sentry');
}
module.exports = {
transpileDependencies: [
'@enso-ui/route-mapper',
'@enso-ui/strings',
'@enso-ui/toastr',
],
publicPath: '/',
outputDir: '../public/',
indexPath: inProduction
? '../resources/views/index.blade.php'
: 'index.html',
pages: {
main: {
entry: 'src/js/enso.js',
minify: !inProduction,
template: inProduction
? '../vendor/laravel-enso/core/stubs/production-index.blade.stub'
: '../vendor/laravel-enso/core/stubs/development-index.stub',
filename: inProduction
? '../resources/views/index.blade.php'
: 'index.html',
},
},
devServer: {
proxy: {
'^/api': {
target: process.env.API_URL,
},
'^/broadcasting': {
target: process.env.API_URL,
},
},
},
configureWebpack: {
devtool: inProduction ? 'hidden-source-map' : 'source-map',
resolve: {
alias: {
'@core': path.resolve(__dirname, '/node_modules/@enso-ui/ui/src'),
'@root': path.resolve(__dirname, '/src/js'),
'@pages': path.resolve(__dirname, '/src/js/pages'),
'@store': path.resolve(__dirname, '/src/js/store'),
'@components': path.resolve(__dirname, '/src/js/components'),
},
},
plugins: [
inProduction && usesSentry && new SentryWebpackPlugin({
include: '../public',
ignoreFile: '.sentrycliignore',
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
release: process.env.SENTRY_RELEASE,
ignore: ['vendor'],
}),
new CopyPlugin({
patterns: [{
from: '../resources/images',
to: 'images',
force: true,
}],
}),
].filter(p => p),
},
chainWebpack: config => {
const scssRules = config.module.rule('scss').oneOfs;
const normalRule = scssRules.store.get('normal');
const lazyRule = config.module.rule('scss').oneOf('scss-lazy');
normalRule.uses.values().forEach(use => {
if (use.name !== 'vue-style-loader') {
lazyRule.use(use.name).merge(use.entries());
return;
}
lazyRule.use('style-loader')
.loader('style-loader')
.options({
injectType: 'lazyStyleTag',
insert: function insertAtTop(element) {
const parent = document.querySelector('head');
parent.insertBefore(element, parent.firstChild);
},
});
});
lazyRule.test(/\.lazy\.scss$/);
scssRules.store.delete('normal', 'scss-lazy');
scssRules.store.set('scss-lazy', lazyRule);
scssRules.store.set('normal', normalRule);
config.module
.rule('images')
.use('url-loader')
.tap(options => ({
...options, name: 'images/[name].[ext]',
}));
config.module
.rule('svg')
.use('file-loader')
.tap(options => ({
...options, name: 'images/[name].[ext]',
}));
},
css: {
sourceMap: true,
extract: false,
},
};