-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
38 lines (33 loc) · 936 Bytes
/
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
const mix = require('laravel-mix')
const fs = require('fs')
const assert = require('assert')
const path = require('path');
const resolveConfig = require('tailwindcss/resolveConfig')
class TailwindExtract {
/**
* Registers the plugin.
*
* @param {*} src
* @param {string} outputPath
*/
register(src = 'tailwind.config.js', outputPath = 'tailwind.json') {
let tailwindConfigPath = path.resolve(src);
this.outputPath = outputPath;
assert(
File.exists(tailwindConfigPath),
'Could not resolve Tailwind CSS config.'
);
let config = require(tailwindConfigPath)
return this.json = resolveConfig(config).theme
}
/**
* Boot
*/
boot() {
fs.writeFileSync(
path.resolve(this.outputPath),
JSON.stringify(this.json)
);
}
}
mix.extend('tailwindExtract', new TailwindExtract())