Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: addTemplate call compats low version nuxt #225

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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