forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandalone.js
More file actions
65 lines (56 loc) · 2.37 KB
/
standalone.js
File metadata and controls
65 lines (56 loc) · 2.37 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
let log = require('tailwindcss/lib/util/log').default
let localModules = {
'tailwindcss/colors': require('tailwindcss/colors'),
'tailwindcss/defaultConfig': require('tailwindcss/defaultConfig'),
'tailwindcss/defaultTheme': require('tailwindcss/defaultTheme'),
'tailwindcss/resolveConfig': require('tailwindcss/resolveConfig'),
'tailwindcss/plugin': require('tailwindcss/plugin'),
'@tailwindcss/aspect-ratio': require('@tailwindcss/aspect-ratio'),
'@tailwindcss/container-queries': require('@tailwindcss/container-queries'),
'@tailwindcss/forms': require('@tailwindcss/forms'),
'@tailwindcss/line-clamp': () => {
log.warn('line-clamp-in-core', [
'As of Tailwind CSS v3.3, the `@tailwindcss/line-clamp` plugin is now included by default.',
'Remove it from the `plugins` array in your configuration to eliminate this warning.',
])
},
'@tailwindcss/typography': require('@tailwindcss/typography'),
// These are present to allow them to be specified in the PostCSS config file
autoprefixer: require('autoprefixer'),
tailwindcss: require('tailwindcss'),
}
// Swap out the default JITI implementation with one that has the built-in modules above preloaded as "native modules"
// NOTE: This uses a private, internal API of Tailwind CSS and is subject to change at any time
let { useCustomJiti } = require('tailwindcss/lib/lib/load-config')
let { transform } = require('sucrase')
useCustomJiti(() =>
require('jiti')(__filename, {
interopDefault: true,
nativeModules: Object.keys(localModules),
transform: (opts) => {
// Sucrase can't transform import.meta so we have to use Babel
if (opts.source.includes('import.meta')) {
return require('jiti/dist/babel.js')(opts)
}
return transform(opts.source, {
transforms: ['typescript', 'imports'],
})
},
})
)
let { patchRequire } = require('./patch-require.js')
patchRequire(
// Patch require(…) to return the bundled modules above so they don't need to be installed
localModules,
// Create a require cache that maps module IDs to module objects
// This MUST be done before require is patched to handle caching
Object.fromEntries(
Object.keys(localModules).map((id) => [
id,
id === '@tailwindcss/line-clamp'
? `node_modules/@tailwindcss/line-clamp/`
: require.cache[require.resolve(id)],
])
)
)
require('tailwindcss/lib/cli')