Как использовать несколько плагинов next.js (машинопись и стилус) - PullRequest
0 голосов
/ 11 мая 2018

Я пытаюсь создать проект next.js с использованием машинописи и стилуса, используя next-compose-plugins .

My next.config.js:

const withPlugins = require('next-compose-plugins')
const withTypescript = require('@zeit/next-typescript')
const withStylus = require('@zeit/next-stylus')

module.exports = withPlugins([

  [withTypescript, {
    webpack(config, options) {
      config.node = {
        fs: 'empty',
      }

      return config
    },
    typescriptLoaderOptions: {
      transpileOnly: false,
    }
  }],

  [withStylus, {
    cssModules: true,
  }],

])

В моем button.tsx я импортирую файл стилуса:

import styles from './button.styl'
console.log(styles) // undefined

button.styl содержит имена классов, которые я хотел бы использовать в своих компонентах, но вместо этого получаю undefined.

IЯ добавил declare module '*.styl' в мой externals.d.ts и включил его в include раздел tsconfig.json

Что я делаю не так?

UPD: получениета же проблема для @zeit/next-css.

1 Ответ

0 голосов
/ 15 мая 2018

@ zeit / next-typescript 1.0.0 выпущен 3 дня назад, и выдает ошибку с typescriptLoaderOptions:

Error: `typescriptLoaderOptions` in next.config.js is no longer supported. https://err.sh/next-plugins/typescript-loader-options
    at module.exports (/Users/set0gut1/tmp/stackoverflow/nextjs/node_modules/@zeit/next-typescript/index.js:15:11)

В этой версии я могу импортировать файл стилуса.

  • next.config.js: удалить typescriptLoaderOptions из вашего.
  • Я не делаю externals.d.ts
  • index.tsx:

import styles from './button.styl'
console.log(styles) // { 'button-class-name': '_1U60cMSmedjISleJqYp7tU' }

export default () => {
    return <div>test</div>
}
...