Skip to content

Commit 0fdc232

Browse files
committed
prepare for tailwind 1.0.0
1 parent 39dea49 commit 0fdc232

File tree

5 files changed

+54
-69
lines changed

5 files changed

+54
-69
lines changed

generator/index.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ function readPostcssConfig(generator) {
2828
return {};
2929
}
3030

31+
function generateConfig(option) {
32+
const args = ['init'];
33+
if (option === 'full') {
34+
args.push('--full');
35+
}
36+
const { spawnSync } = require('child_process');
37+
spawnSync('./node_modules/.bin/tailwind', args);
38+
}
39+
3140
module.exports = (api, options) => {
3241
const postcss = readPostcssConfig(api.generator);
3342
const configs = {
3443
postcss: {
3544
plugins: {
36-
tailwindcss: './tailwind.config.js',
45+
tailwindcss: {},
3746
'vue-cli-plugin-tailwind/purgecss': {},
3847
},
3948
},
@@ -46,8 +55,20 @@ module.exports = (api, options) => {
4655
api.injectImports(api.entryFile, `import './assets/tailwind.css'`);
4756
api.render('./template');
4857

49-
api.onCreateComplete(() => {
50-
const { spawnSync } = require('child_process');
51-
spawnSync('./node_modules/.bin/tailwind', ['init', 'tailwind.config.js']);
52-
});
58+
if (options.overwriteConfig) {
59+
const filename = 'tailwind.config.js';
60+
delete api.generator.files[filename];
61+
const configPath = path.join(api.generator.context, filename);
62+
try {
63+
fs.unlinkSync(configPath);
64+
} catch (error) {
65+
throw new Error(error);
66+
}
67+
}
68+
69+
if (options.initConfig && options.overwriteConfig !== false) {
70+
api.onCreateComplete(() => {
71+
generateConfig(options.initConfig);
72+
});
73+
}
5374
};
Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,5 @@
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;
1+
@tailwind base;
132

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-
*/
213
@tailwind components;
224

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-
*/
475
@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-
*/

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-tailwind",
3-
"version": "0.4.2",
3+
"version": "1.0.0-beta.1",
44
"description": "vue-cli plugin for Tailwind CSS",
55
"author": "Jens Eggerstedt <j.eggerstedt@kaibatech.de>",
66
"license": "MIT",
@@ -19,9 +19,6 @@
1919
],
2020
"dependencies": {
2121
"@fullhuman/postcss-purgecss": "^1.1.0",
22-
"tailwindcss": "^0.7.4"
23-
},
24-
"peerDependencies": {
25-
"@vue/cli-shared-utils": "^3.0.0"
22+
"tailwindcss": "^1.0.0-beta.3"
2623
}
2724
}

prompts.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs');
2+
3+
module.exports = [
4+
{
5+
type: 'list',
6+
name: 'initConfig',
7+
message: 'Generate tailwind.config.js',
8+
choices: [
9+
{ name: 'none', value: false },
10+
{ name: 'minimal', value: 'minimal' },
11+
{ name: 'full', value: 'full' },
12+
],
13+
default: 1,
14+
},
15+
{
16+
name: 'overwriteConfig',
17+
type: 'confirm',
18+
message: 'tailwind.config.js already exists! Do you want to overwrite?',
19+
default: false,
20+
when: answers => {
21+
return answers.initConfig && fs.existsSync('./tailwind.config.js');
22+
},
23+
},
24+
];

purgecss/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TailwindExtractor {
88
}
99

1010
let config = {
11-
content: ['./public/index.html', './src/**/*.vue'],
11+
content: ['./public/**/*.html', './src/**/*.vue'],
1212
extractors: [
1313
{
1414
extractor: TailwindExtractor,

0 commit comments

Comments
 (0)