-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
40 lines (31 loc) · 1.07 KB
/
index.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
let mix = require('laravel-mix');
let fs = require('fs')
class Tailwind {
dependencies() {
this.requiresReload = `
Tailwind has now been installed. Please ensure that
your configuration file (tailwind.js or tailwind.config.js)
has been created (node_modules/.bin/tailwind init),
and then run "npm run dev" again.
`;
return ['tailwindcss'];
}
register(oldConfigPath = './tailwind.js') {
let newConfigPath = './tailwind.config.js';
if (fs.existsSync(oldConfigPath)) {
this.configPath = oldConfigPath;
} else if (fs.existsSync(newConfigPath)) {
this.configPath = newConfigPath;
} else {
throw 'Error: Files tailwind.js or tailwind.config.js don\'t exist.';
}
}
boot() {
if (Mix.components.has('sass')) {
Config.processCssUrls = false;
}
let tailwindcss = require('tailwindcss');
Config.postCss.push(tailwindcss(this.configPath));
}
}
mix.extend('tailwind', new Tailwind());