|
1 | 1 | function TailwindPlugin(api, options) { |
2 | | - const { |
3 | | - tailwindConfig, |
4 | | - purgeConfig, |
5 | | - presetEnvConfig, |
6 | | - shouldImport, |
7 | | - shouldPurge, |
8 | | - shouldTimeTravel |
9 | | - } = options; |
| 2 | + const { |
| 3 | + tailwindConfig, |
| 4 | + purgeConfig, |
| 5 | + presetEnvConfig, |
| 6 | + shouldImport, |
| 7 | + shouldPurge, |
| 8 | + shouldTimeTravel |
| 9 | + } = options; |
10 | 10 |
|
11 | | - const postcssImport = require('postcss-import')(); |
| 11 | + const postcssImport = require('postcss-import')(); |
12 | 12 |
|
13 | | - const tailwind = tailwindConfig ? |
14 | | - require('tailwindcss')(tailwindConfig) : |
15 | | - require('tailwindcss'); |
| 13 | + const tailwind = tailwindConfig ? |
| 14 | + require('tailwindcss')(tailwindConfig) : |
| 15 | + require('tailwindcss'); |
16 | 16 |
|
17 | | - const postcssPresetEnv = require('postcss-preset-env')(presetEnvConfig); |
18 | | - const purgecss = require('@fullhuman/postcss-purgecss')(purgeConfig); |
| 17 | + const postcssPresetEnv = require('postcss-preset-env')(presetEnvConfig); |
| 18 | + const purgecss = require('@fullhuman/postcss-purgecss')(purgeConfig); |
19 | 19 |
|
20 | | - api.chainWebpack(config => { |
21 | | - // I'm giving into peer pressure. |
22 | | - ['css', 'scss', 'sass', 'less', 'stylus', 'postcss'].forEach(lang => { |
23 | | - config.module |
24 | | - .rule(lang) |
25 | | - .oneOf('normal') |
26 | | - .use('postcss-loader') |
27 | | - .tap(options => { |
28 | | - options.plugins.unshift( |
29 | | - ...[ |
30 | | - shouldImport && postcssImport, |
31 | | - tailwind, |
32 | | - shouldTimeTravel && postcssPresetEnv |
33 | | - ] |
34 | | - ); |
| 20 | + api.chainWebpack(config => { |
| 21 | + // I'm giving into peer pressure. |
| 22 | + ['css', 'scss', 'sass', 'less', 'stylus', 'postcss'].forEach(lang => { |
| 23 | + config.module |
| 24 | + .rule(lang) |
| 25 | + .oneOf('normal') |
| 26 | + .use('postcss-loader') |
| 27 | + .tap(options => { |
| 28 | + options.plugins.unshift( |
| 29 | + ...[ |
| 30 | + shouldImport && postcssImport, |
| 31 | + tailwind, |
| 32 | + shouldTimeTravel && postcssPresetEnv |
| 33 | + ] |
| 34 | + ); |
35 | 35 |
|
36 | | - // eslint-disable-next-line no-unused-expressions |
37 | | - process.env.NODE_ENV === 'production' && |
| 36 | + // eslint-disable-next-line no-unused-expressions |
| 37 | + process.env.NODE_ENV === 'production' && |
38 | 38 | shouldPurge && |
39 | 39 | options.plugins.push(purgecss); |
40 | 40 |
|
41 | | - return options; |
42 | | - }); |
43 | | - }); |
44 | | - }); |
| 41 | + return options; |
| 42 | + }); |
| 43 | + }); |
| 44 | + }); |
45 | 45 | } |
46 | 46 |
|
47 | 47 | TailwindPlugin.defaultOptions = () => ({ |
48 | | - shouldPurge: true, |
49 | | - shouldImport: true, |
50 | | - shouldTimeTravel: true, |
51 | | - tailwindConfig: undefined, |
52 | | - presetEnvConfig: { |
53 | | - stage: 0, |
54 | | - autoprefixer: false |
55 | | - }, |
56 | | - purgeConfig: { |
57 | | - keyframes: true, |
58 | | - content: [ |
59 | | - './src/**/*.vue', |
60 | | - './src/**/*.js', |
61 | | - './src/**/*.jsx', |
62 | | - './src/**/*.ts', |
63 | | - './src/**/*.tsx', |
64 | | - './src/**/*.html', |
65 | | - './src/**/*.pug', |
66 | | - './src/**/*.md', |
67 | | - './src/**/*.svg' |
68 | | - ], |
69 | | - whitelist: [ |
70 | | - 'body', |
71 | | - 'html', |
72 | | - 'img', |
73 | | - 'a', |
74 | | - 'g-image', |
75 | | - 'g-image--lazy', |
76 | | - 'g-image--loaded', |
77 | | - 'active', |
78 | | - 'active--exact' |
79 | | - ], |
| 48 | + shouldPurge: true, |
| 49 | + shouldImport: true, |
| 50 | + shouldTimeTravel: true, |
| 51 | + tailwindConfig: undefined, |
| 52 | + presetEnvConfig: { |
| 53 | + stage: 0, |
| 54 | + autoprefixer: false |
| 55 | + }, |
| 56 | + purgeConfig: { |
| 57 | + keyframes: true, |
| 58 | + content: [ |
| 59 | + './src/**/*.vue', |
| 60 | + './src/**/*.js', |
| 61 | + './src/**/*.jsx', |
| 62 | + './src/**/*.ts', |
| 63 | + './src/**/*.tsx', |
| 64 | + './src/**/*.html', |
| 65 | + './src/**/*.pug', |
| 66 | + './src/**/*.md', |
| 67 | + './src/**/*.svg' |
| 68 | + ], |
| 69 | + whitelist: [ |
| 70 | + 'body', |
| 71 | + 'html', |
| 72 | + 'img', |
| 73 | + 'a', |
| 74 | + 'g-image', |
| 75 | + 'g-image--lazy', |
| 76 | + 'g-image--loaded', |
| 77 | + 'active', |
| 78 | + 'active--exact' |
| 79 | + ], |
80 | 80 | whitelistPatterns: [ |
81 | 81 | /shiki/, |
82 | 82 | /prism/, |
83 | 83 | /markdown/, |
84 | 84 | /.*-(enter|enter-active|enter-to|leave|leave-active|leave-to)/, |
85 | | - /data-v-.*/ |
| 85 | + /data-v-.*/, |
| 86 | + />>>/, |
| 87 | + /::v-deep/ |
86 | 88 | ], |
87 | | - defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [] |
88 | | - } |
| 89 | + defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [] |
| 90 | + } |
89 | 91 | }); |
90 | 92 |
|
91 | 93 | module.exports = TailwindPlugin; |
0 commit comments