This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
vue.config.js
124 lines (110 loc) · 3.05 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
const { createLoader } = require("simple-functional-loader");
const webpack = require("webpack");
const path = require("path");
const fs = require("fs");
const externals = {
resolve: "self.resolve",
chokidar: "self.chokidar",
purgecss: "self.purgecss",
tmp: 'self.tmp',
};
const moduleOverrides = {
fs: path.resolve(__dirname, "src/modules/fs.js"),
};
function getExternal(context, request, callback) {
if (/node_modules/.test(context) && externals[request]) {
return callback(null, externals[request]);
}
callback();
}
const files = [
{
pattern: /modern-noramlize/,
file: require.resolve("modern-normalize"),
},
{
pattern: /normalize/,
file: require.resolve("normalize.css"),
},
{
pattern: /preflight/,
file: path.resolve(
__dirname,
"node_modules/tailwindcss/lib/plugins/css/preflight.css"
),
},
];
module.exports = {
productionSourceMap: false,
configureWebpack: (config) => {
config.resolve.alias = { ...config.resolve.alias, ...moduleOverrides };
config.plugins.push(
new webpack.DefinePlugin({
"process.env.TAILWIND_MODE": JSON.stringify("build"),
"process.env.TAILWIND_DISABLE_TOUCH": true,
})
);
// there's some node-specific stuff in parse-glob
// we don't use globs though so this can be overridden
config.module.rules.push({
test: require.resolve('tailwindcss/node_modules/glob-parent'),
use: [
createLoader(function(_source) {
return `module.exports = () => ''`;
}),
],
});
config.module.rules.push({
test: require.resolve('is-glob'),
use: [
createLoader(function(_source) {
return `module.exports = () => false`;
}),
],
});
config.module.rules.push({
test: require.resolve('tailwindcss/node_modules/fast-glob'),
use: [
createLoader(function (_source) {
return `module.exports = {
sync: (patterns) => [].concat(patterns)
}`
}),
],
})
config.module.rules.push({
test: require.resolve("tailwindcss/lib/jit/processTailwindFeatures.js"),
use: createLoader(function(source) {
return source.replace(`let warned = false;`, `let warned = true;`);
}),
});
config.module.rules.push({
test: require.resolve("tailwindcss/lib/plugins/preflight.js"),
use: createLoader(function(source) {
return source.replace(
/_fs\.default\.readFileSync\(.*?'utf8'\)/g,
(m) => {
for (let i = 0; i < files.length; i++) {
if (
files[i].pattern.test(m)
) {
return (
"`" +
fs.readFileSync(files[i].file, "utf8").replace(/`/g, "\\`") +
"`"
);
}
}
return m;
}
);
}),
});
config.output.globalObject = "self";
if (config.externals) {
config.externals.push(getExternal);
} else {
config.externals = [getExternal];
}
},
};