Skip to content

Commit b18380d

Browse files
zcqno1sponge
and
sponge
authored
fix: addTemplate call compats low version nuxt (#225)
Co-authored-by: sponge <[email protected]>
1 parent 9a3ebc2 commit b18380d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/module.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const logger = require('./logger')
77
const defaultTailwindConfig = require('./files/tailwind.config.js')
88

99
module.exports = async function (moduleOptions) {
10-
const { nuxt, addTemplate } = this
10+
const { nuxt } = this
1111
const options = defu.arrayFn(moduleOptions, nuxt.options.tailwindcss, {
1212
configPath: 'tailwind.config.js',
1313
cssPath: join(nuxt.options.dir.assets, 'css', 'tailwind.css'),
@@ -99,7 +99,11 @@ module.exports = async function (moduleOptions) {
9999
const resolvedConfig = resolveConfig(tailwindConfig)
100100

101101
// Render as a json file in buildDir
102-
addTemplate({
102+
/**
103+
* nuxt ModuleContainer bind 'this' to addTemplate until v2.13.0,use this.addTemplate to compat with low version
104+
* issue: https://github.com/nuxt-community/tailwindcss-module/issues/224
105+
*/
106+
this.addTemplate({
103107
src: resolve(__dirname, 'templates/tailwind.config.json'),
104108
fileName: 'tailwind.config.json',
105109
options: { config: resolvedConfig }

0 commit comments

Comments
 (0)