Skip to content

Commit

Permalink
fix: addTemplate call compats low version nuxt (#225)
Browse files Browse the repository at this point in the history
Co-authored-by: sponge <cengchuanqiu@deepexi.com>
  • Loading branch information
zcqno1 and sponge committed Dec 11, 2020
1 parent 9a3ebc2 commit b18380d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit b18380d

Please sign in to comment.