-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
202 lines (184 loc) · 5.98 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/**
* Configuration for Vue CLI
* @reference https://cli.vuejs.org/config/
*
*/
require("dotenv").config();
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ModuleDependencyWarning = require("webpack/lib/ModuleDependencyWarning");
// are we running debug build?
function isDebug() {
return process.env.NODE_ENV !== "production";
}
class IgnoreNotFoundExportPlugin {
apply(compiler) {
const messageRegExp = /export '.*'( \(reexported as '.*'\))? was not found in/;
function doneHook(stats) {
stats.compilation.warnings = stats.compilation.warnings.filter(function (
warn
) {
if (
warn instanceof ModuleDependencyWarning &&
messageRegExp.test(warn.message)
) {
return false;
}
return true;
});
}
if (compiler.hooks) {
compiler.hooks.done.tap("IgnoreNotFoundExportPlugin", doneHook);
} else {
compiler.plugin("done", doneHook);
}
}
}
// https://stackoverflow.com/questions/53431754/styling-not-applied-to-vue-web-component-during-development
// ?? - if HMR - https://github.com/vuejs/vue-style-loader/pull/41/commits/c722f1cb5c2856a1197a13f04317506453c14add
function enableShadowCss(config) {
const configs = [
config.module.rule("vue").use("vue-loader"),
config.module.rule("css").oneOf("vue-modules").use("vue-style-loader"),
config.module.rule("css").oneOf("vue").use("vue-style-loader"),
config.module.rule("css").oneOf("normal-modules").use("vue-style-loader"),
config.module.rule("css").oneOf("normal").use("vue-style-loader"),
config.module.rule("postcss").oneOf("vue-modules").use("vue-style-loader"),
config.module.rule("postcss").oneOf("vue").use("vue-style-loader"),
config.module
.rule("postcss")
.oneOf("normal-modules")
.use("vue-style-loader"),
config.module.rule("postcss").oneOf("normal").use("vue-style-loader"),
config.module.rule("scss").oneOf("vue-modules").use("vue-style-loader"),
config.module.rule("scss").oneOf("vue").use("vue-style-loader"),
config.module.rule("scss").oneOf("normal-modules").use("vue-style-loader"),
config.module.rule("scss").oneOf("normal").use("vue-style-loader"),
config.module.rule("sass").oneOf("vue-modules").use("vue-style-loader"),
config.module.rule("sass").oneOf("vue").use("vue-style-loader"),
config.module.rule("sass").oneOf("normal-modules").use("vue-style-loader"),
config.module.rule("sass").oneOf("normal").use("vue-style-loader"),
config.module.rule("less").oneOf("vue-modules").use("vue-style-loader"),
config.module.rule("less").oneOf("vue").use("vue-style-loader"),
config.module.rule("less").oneOf("normal-modules").use("vue-style-loader"),
config.module.rule("less").oneOf("normal").use("vue-style-loader"),
config.module.rule("stylus").oneOf("vue-modules").use("vue-style-loader"),
config.module.rule("stylus").oneOf("vue").use("vue-style-loader"),
config.module
.rule("stylus")
.oneOf("normal-modules")
.use("vue-style-loader"),
config.module.rule("stylus").oneOf("normal").use("vue-style-loader"),
];
configs.forEach((c) =>
c.tap((options) => {
options.shadowMode = true;
return options;
})
);
}
module.exports = {
filenameHashing: true,
/**
* disables lint on save which disrupts workflow.
* linting reserved for pre-commit git hook.
*/
lintOnSave: false,
devServer: {
// if these options aren't set HMR breaks and debugging remotely fails (say to local to VM)
disableHostCheck: true,
host: 'localhost',
headers: { "Access-Control-Allow-Origin": "*" },
/**
* disables linting overlay which disrupts workflow.
* linting reserved for pre-commit git hook.
*/
overlay: {
error: false,
warning: false,
},
},
css: {
extract: false,
loaderOptions: {
sass: {
prependData: `
@import '@/app/assets/scss/abstracts/_variables.scss';
@import '@/app/assets/scss/abstracts/_mixins.scss';
@import '@/app/assets/scss/vendor/_carbon-components-helpers.scss';
`,
},
},
},
/**
* Progressive Web Application features
* @reference https://cli.vuejs.org/config/#pwa
*
*/
pwa: {
name: "American Whitewater",
themeColor: "#5a6872",
backgroundColor: "#537653",
msTileColor: "#FFFFFF",
assetsVersion: Math.floor(Math.random() * 1000000000),
appleMobileWebAppCapable: "yes",
workboxPluginMode: "InjectManifest",
workboxOptions: {
swSrc: "./src/sw.js",
swDest: "service-worker.js",
},
appleMobileWebAppStatusBarStyle: "black",
},
chainWebpack: (config) => {
config.resolve
.extensions
.prepend('.mjs')
config.module
.rule("file")
.test(/\.(png|mp4|jpe?g|gif)$/i)
.use("file-loader")
.loader("file-loader")
.end();
config.module
.rule('mjs')
.test(/\.mjs$/)
.include
.add(/node_modules/)
.end()
.use("babel-loader")
.loader("babel-loader")
.end()
config.module
.rule('mjs')
.test(/\.mjs$/)
.include
.add(/node_modules/)
.end()
.use("babel-loader")
.loader("babel-loader")
.end()
config
.plugin("IgnoreNotFoundExportPlugin")
.before("friendly-errors")
.use(IgnoreNotFoundExportPlugin);
config.resolve.alias.set(
"tinyqueue",
path.join(__dirname, "/node_modules/tinyqueue/tinyqueue.js")
);
enableShadowCss(config);
},
productionSourceMap: isDebug(), // NOTE: this is default
configureWebpack: (config) => {
config.optimization = {
minimize: !isDebug(),
};
if (isDebug()) {
config.devtool = "source-map";
}
config.output.jsonpFunction = "spa_wh2o_vue";
//config.output.libraryExport = "default";
//return config;
},
publicPath: process.env.VUE_APP_BASE_URL || "/",
};