From b18380dcd529d679314563f54f66dfe84556767c Mon Sep 17 00:00:00 2001 From: Sponge Date: Fri, 11 Dec 2020 18:15:36 +0800 Subject: [PATCH] fix: addTemplate call compats low version nuxt (#225) Co-authored-by: sponge --- lib/module.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/module.js b/lib/module.js index b3ec1720..f24613a0 100644 --- a/lib/module.js +++ b/lib/module.js @@ -7,7 +7,7 @@ const logger = require('./logger') const defaultTailwindConfig = require('./files/tailwind.config.js') module.exports = async function (moduleOptions) { - const { nuxt, addTemplate } = this + const { nuxt } = this const options = defu.arrayFn(moduleOptions, nuxt.options.tailwindcss, { configPath: 'tailwind.config.js', cssPath: join(nuxt.options.dir.assets, 'css', 'tailwind.css'), @@ -99,7 +99,11 @@ module.exports = async function (moduleOptions) { const resolvedConfig = resolveConfig(tailwindConfig) // Render as a json file in buildDir - addTemplate({ + /** + * nuxt ModuleContainer bind 'this' to addTemplate until v2.13.0,use this.addTemplate to compat with low version + * issue: https://github.com/nuxt-community/tailwindcss-module/issues/224 + */ + this.addTemplate({ src: resolve(__dirname, 'templates/tailwind.config.json'), fileName: 'tailwind.config.json', options: { config: resolvedConfig }