Skip to content

Commit 81dfd11

Browse files
committed
init commit
0 parents  commit 81dfd11

File tree

6 files changed

+145
-0
lines changed

6 files changed

+145
-0
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
node_modules
3+
yarn.lock
4+
5+
# Log files
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
# Editor directories and files
11+
.idea
12+
.vscode
13+
*.suo
14+
*.ntvs*
15+
*.njsproj
16+
*.sln
17+
*.sw*

generator/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = (api, options) => {
2+
const configs = {
3+
postcss: {
4+
plugins: {
5+
tailwindcss: './tailwind.config.js',
6+
},
7+
},
8+
};
9+
api.addConfigTransform('postcss', {
10+
file: {
11+
js: ['postcss.config.js'],
12+
json: ['.postcssrc.json', '.postcssrc'],
13+
yaml: ['.postcssrc.yaml', '.postcssrc.yml'],
14+
},
15+
});
16+
api.extendPackage(configs);
17+
18+
api.injectImports(api.entryFile, `import './assets/tailwind.css'`);
19+
api.render('./template');
20+
21+
api.onCreateComplete(() => {
22+
const { spawnSync } = require('child_process');
23+
spawnSync('./node_modules/.bin/tailwind', ['init', 'tailwind.config.js']);
24+
});
25+
};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* This injects Tailwind's base styles, which is a combination of
3+
* Normalize.css and some additional base styles.
4+
*
5+
* You can see the styles here:
6+
* https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css
7+
*
8+
* If using `postcss-import`, use this import instead:
9+
*
10+
* @import "tailwindcss/preflight";
11+
*/
12+
@tailwind preflight;
13+
14+
/**
15+
* This injects any component classes registered by plugins.
16+
*
17+
* If using `postcss-import`, use this import instead:
18+
*
19+
* @import "tailwindcss/components";
20+
*/
21+
@tailwind components;
22+
23+
/**
24+
* Here you would add any of your custom component classes; stuff that you'd
25+
* want loaded *before* the utilities so that the utilities could still
26+
* override them.
27+
*
28+
* Example:
29+
*
30+
* .btn { ... }
31+
* .form-input { ... }
32+
*
33+
* Or if using a preprocessor or `postcss-import`:
34+
*
35+
* @import "components/buttons";
36+
* @import "components/forms";
37+
*/
38+
39+
/**
40+
* This injects all of Tailwind's utility classes, generated based on your
41+
* config file.
42+
*
43+
* If using `postcss-import`, use this import instead:
44+
*
45+
* @import "tailwindcss/utilities";
46+
*/
47+
@tailwind utilities;
48+
49+
/**
50+
* Here you would add any custom utilities you need that don't come out of the
51+
* box with Tailwind.
52+
*
53+
* Example :
54+
*
55+
* .bg-pattern-graph-paper { ... }
56+
* .skew-45 { ... }
57+
*
58+
* Or if using a preprocessor or `postcss-import`:
59+
*
60+
* @import "utilities/background-patterns";
61+
* @import "utilities/skew-transforms";
62+
*/

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = () => {};

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "vue-cli-plugin-tailwind",
3+
"version": "0.1.0",
4+
"author": "Jens Eggerstedt <j.eggerstedt@kaibatech.de>",
5+
"license": "MIT",
6+
"dependencies": {
7+
"glob-all": "^3.1.0",
8+
"purgecss-webpack-plugin": "^1.3.0",
9+
"tailwindcss": "^0.6.5"
10+
},
11+
"keywords": [
12+
"vue",
13+
"cli",
14+
"plugin",
15+
"tailwind",
16+
"purgecss"
17+
]
18+
}

webpack/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require('path');
2+
const glob = require('glob-all');
3+
const PurgecssPlugin = require('purgecss-webpack-plugin');
4+
5+
class TailwindExtractor {
6+
static extract(content) {
7+
return content.match(/[A-Za-z0-9-_:\/]+/g) || [];
8+
}
9+
}
10+
11+
module.exports = new PurgecssPlugin({
12+
paths: glob.sync([
13+
path.join(process.cwd(), 'public/index.html'),
14+
path.join(process.cwd(), 'src/**/*.vue'),
15+
]),
16+
extractors: [
17+
{
18+
extractor: TailwindExtractor,
19+
extensions: ['html', 'js', 'vue'],
20+
},
21+
],
22+
});

0 commit comments

Comments
 (0)