-
Notifications
You must be signed in to change notification settings - Fork 81
/
vue.config.js
138 lines (119 loc) · 3.25 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
const HOST_NAME = 'localhost'
const dotenv = require('dotenv')
const path = require('path')
const fs = require('fs')
const BundleTrackerPlugin = require('webpack-bundle-tracker')
const CompressionPlugin = require('compression-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const MomentLocalesPlugin = require('moment-locales-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
dotenv.config({
path: './sapl/.env'
})
module.exports = {
runtimeCompiler: true,
publicPath:
process.env.NODE_ENV === 'production'
? '/static/sapl/frontend'
: `http://${HOST_NAME}:8080/`,
outputDir: './sapl/static/sapl/frontend',
productionSourceMap: false,
css: {
sourceMap: true
},
devServer: {
port: '8080',
hot: true,
https: false,
headers: {
'Access-Control-Allow-Origin': '*'
},
static: {
directory: path.join(__dirname, 'frontend', 'src', 'assets'),
publicPath: ''
// path.join(__dirname + '/frontend/', 'src', 'assets'),
}
},
chainWebpack: (config) => {
config.plugins.delete('html')
config.plugins.delete('preload')
config.plugins.delete('prefetch')
config.resolve.alias.set('@', path.join(__dirname, 'frontend', 'src'))
config.resolve.alias.set('__STATIC__', 'static')
config
.plugin('BundleTrackerPlugin')
.use(BundleTrackerPlugin, [
{
path: '.',
filename: `./frontend/${
process.env.DEBUG === 'True' &&
process.env.NODE_ENV !== 'production'
? 'dev-'
: ''
}webpack-stats.json`
}
])
config.plugin('provide').use(require('webpack').ProvidePlugin, [
{
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery: 'jquery',
_: 'lodash'
}
])
config.plugin('MomentLocalesPlugin').use(MomentLocalesPlugin, [
{
localesToKeep: ['pt-BR']
}
])
config.plugin('copy').use(CopyPlugin, [
{
patterns: [
{
from: path.join(__dirname, 'frontend', 'src', 'assets'),
to: '.'
},
{
from: path.join(__dirname, 'node_modules/tinymce/skins'),
to: 'js/skins/[path][name][ext]'
}
]
}
])
if (process.env.NODE_ENV === 'production') {
fs.unlink('frontend/dev-webpack-stats.json', function (err) {
if (err && err.code !== 'ENOENT') {
console.error('Error occurred while trying to remove file')
}
})
config
.plugin('CompressionPlugin')
.use(CompressionPlugin, [{}])
config
.optimization
.minimizer('terser')
.use(TerserPlugin, [{
extractComments: true,
minify: TerserPlugin.uglifyJsMinify
}])
}
config.entryPoints.delete('app')
config
.entry('global')
.add('./frontend/src/__global/main.js')
.end()
config
.entry('parlamentar')
.add('./frontend/src/__apps/parlamentar/main.js')
.end()
config
.entry('painel')
.add('./frontend/src/__apps/painel/main.js')
.end()
config
.entry('compilacao')
.add('./frontend/src/__apps/compilacao/main.js')
.end()
}
}