forked from chasegiunta/craft-vue-tailwind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
86 lines (82 loc) · 2.76 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
const path = require("path");
const ManifestPlugin = require("webpack-manifest-plugin");
const PurgecssPlugin = require("purgecss-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const whitelister = require("purgecss-whitelister");
const glob = require("glob-all");
const FileManagerPlugin = require("filemanager-webpack-plugin");
modern = process.env.VUE_CLI_MODERN_MODE;
production = process.env.NODE_ENV === "production";
config = {
protocol: "http",
host: "localhost",
port: 8080,
watchDir: "templates",
// Whitelist selectors to stop purgecss from removing them from your CSS
// You can pass in whole stylesheets to whitelist everything from thirdparty libs
// Accepts string paths, array of strings, globby strings, or array of globby strings:
// ['./node_modules/lib1/*.css', './node_modules/lib2/*.scss']
purgecssWhitelist: [],
// Whitelist based on a regular expression.
// Ex: [/red$/] (selectors ending in 'red' will remain)
// https://www.purgecss.com/whitelisting
purgecssWhitelistPatterns: [],
};
// Custom PurgeCSS extractor for Tailwind that allows special characters in
// class names.
// https://github.com/FullHuman/purgecss#extractor
class TailwindExtractor {
static extract(content) {
return content.match(/[A-z0-9-:\/]+/g) || [];
}
}
module.exports = {
runtimeCompiler: true,
publicPath: `${config.protocol}://${config.host}:${config.port}/`,
outputDir: "web/dist",
filenameHashing: true,
css: {
sourceMap: true,
},
devServer: {
https: config.https,
host: config.host,
port: config.port,
clientLogLevel: "info",
headers: { "Access-Control-Allow-Origin": "*" },
disableHostCheck: true,
contentBase: path.join(__dirname, config.watchDir),
watchContentBase: true,
},
configureWebpack: {
plugins: [
new ManifestPlugin({
fileName: modern ? "manifest.json" : "manifest-legacy.json",
publicPath: production ? "/dist/" : "/",
}),
new PurgecssPlugin({
paths: glob.sync([
path.join(__dirname, "./templates/**/*.html"),
path.join(__dirname, "./templates/**/*.twig"),
path.join(__dirname, "./src/**/*.vue"),
path.join(__dirname, "./src/**/*.js"),
]),
whitelist: whitelister(config.purgecssWhitelist),
whitelistPatterns: config.purgecssWhitelistPatterns,
extractors: [
{
extractor: TailwindExtractor,
// Specify the file extensions to include when scanning for class names.
extensions: ["html", "js", "twig", "vue"],
},
],
}),
new FileManagerPlugin({
onEnd: {
// Delete unnecessary index.html file
delete: ["./web/dist/index.html"],
},
}),
],
},
};