-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
executable file
·122 lines (105 loc) · 3.38 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
// const CSSLoaderResolver = require('@vue/cli-service/lib/webpack/CSSLoaderResolver')
// const langs = ['css', 'scss'] // I only care about these languages for now
// const isProd = process.env.NODE_ENV === 'production'
// const cssExtract = false
// const postCSS = true
// const sourceMap = true
// const userOptions = {
// lintOnSave: false,
// dll: true,
// css: {
// extract: cssExtract,
// sourceMap: sourceMap
// }
// }
// module.exports = Object.assign({}, userOptions, {
// chainWebpack: config => {
// // Customize CSS/SCSS loaders to handle relative paths
// // Taking cues from @vue/cli-service/lib/config/css.js
// const baseOptions = Object.assign({}, userOptions, {
// sourceMap: sourceMap, // This was the missing option!
// extract: isProd && userOptions.extract !== false,
// minimize: isProd,
// postcss: true
// })
// const resolver = new CSSLoaderResolver(baseOptions)
// for (const lang of langs) {
// // Remove existing rule
// config.module.rules.delete(lang)
// // Pull rule from default resolver for this language
// const rule = resolver[lang]()
// // Make an array of uses returned by the default resolver, in order
// const newUses = []
// for (const use of rule.use) {
// newUses.push(use)
// // Inject resolve-url-loader right after css-loader
// if (use.loader === 'css-loader') {
// newUses.push({
// loader: 'resolve-url-loader',
// options: {
// sourceMap: sourceMap
// }
// })
// }
// }
// // Set up a new rule for the language in this context
// const context = config.module
// .rule(lang)
// .test(rule.test)
// .include
// .add(filepath => {
// // Not ends with `.module.xxx`
// return !/\.module\.[a-z]+$/.test(filepath)
// })
// .end()
// // Now apply the new array of uses
// newUses.forEach(use => {
// context
// .use(use.loader)
// .loader(use.loader)
// .options(use.options)
// })
// }
// }
// })
// ----
module.exports = {
lintOnSave: false,
// https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders
// making variable.scss available to all sass files, including .vue
css: {
sourceMap: true, // to enable resolve-url-loader
loaderOptions: {
sass: {
data: '@import "@/assets/styles/variables.scss";'
}
}
},
// TODO: adicionar resolve-url-loader
// @see https://forum.vuejs.org/t/using-resolve-url-loader-with-vue-cli-3-0-0/33036/3
// @see https://github.com/mozilla-neutrino/webpack-chain/issues/28#issuecomment-334528021
chainWebpack: config => {
// descoberto via `vue inspect`
// TODO: deve ser necessário adicionar as mesmas regras para oneOf('vue')
config.module.rule('scss')
.oneOf('normal')
.use('resolve-url-loader')
.loader('resolve-url-loader')
.options({
attempts: 1
})
.after('css-loader')
config.module.rule('sass')
.oneOf('normal')
.use('resolve-url-loader')
.loader('resolve-url-loader')
.options({
attempts: 1
})
.after('css-loader')
},
baseUrl: '',
pluginOptions: {
cordovaPath: '.'
}
};