question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: options.postcss is not a function This error occurred during the build process and can only be dismissed by fixing the error.

See original GitHub issue

I can’t setup vanilla-extract on nextjs application. tell me solution plz.

console

% npm run -w next-template dev --

> next-template@0.1.0 dev
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
event - compiled client and server successfully in 5.5s (171 modules)
wait  - compiling /_error (client and server)...
event - compiled client and server successfully in 126 ms (172 modules)
wait  - compiling / (client and server)...
error - ../node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[3].oneOf[0].use[1]!../node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[3].oneOf[0].use[2]!../node_modules/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?{"source":"LkhlbGxvV29ybGRfXzFhcDQ2NDIwIHsKICBjb2xvcjogYmx1ZTsKfQ=="}!../node_modules/@vanilla-extract/webpack-plugin/extracted/dist/vanilla-extract-webpack-plugin-extracted.cjs.js
TypeError: options.postcss is not a function
(node:8385) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)

packaje.json

  "devDependencies": {
    "@types/jest": "^27.0.3",
    "@types/node": "^16.11.11",
    "@typescript-eslint/eslint-plugin": "^5.5.0",
    "@typescript-eslint/parser": "^5.5.0",
    "@vanilla-extract/babel-plugin": "^1.1.3",
    "@vanilla-extract/css": "^1.6.8",
    "@vanilla-extract/next-plugin": "^1.0.1",
    "esbuild": "^0.14.2",
    "esbuild-jest": "^0.5.0",
    "esbuild-register": "^3.2.0",
    "eslint": "^8.4.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "jest": "^27.4.3",
    "next": "12.0.7",
    "npm-check-updates": "^12.0.2",
    "prettier": "^2.5.1",
    "typescript": "^4.5.2"
  }

next.config.js

const { createVanillaExtractPlugin } = require('@vanilla-extract/next-plugin');
const withVanillaExtract = createVanillaExtractPlugin();

/** @type {import('next').NextConfig} */
const config = {
  // reactStrictMode: true,
};

module.exports = withVanillaExtract(config);

index.tsx

import type { NextPage } from 'next';

import { HelloWorld } from '../components/HelloWorld';

const Home: NextPage = () => {
  return <HelloWorld />;
};

export default Home;

components/HelloWorld

import * as React from 'react';

import { className } from './HelloWorld.css';

export const HelloWorld = () => {
  return <p {...{ className }}>Hello World</p>;
};

componens/HelloWorld.css.ts

import { style } from '@vanilla-extract/css';

export const className = style({
  color: 'blue',
});

error output in browser

Failed to compile
next-template/components/HelloWorld.css.ts.vanilla.css!=!../node_modules/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?{"source":"LkhlbGxvV29ybGRfXzFhcDQ2NDIwIHsKICBjb2xvcjogYmx1ZTsKfQ=="}!../node_modules/@vanilla-extract/webpack-plugin/extracted/dist/vanilla-extract-webpack-plugin-extracted.cjs.js
TypeError: options.postcss is not a function
This error occurred during the build process and can only be dismissed by fixing the error.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:13
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
markdalgleishcommented, Dec 20, 2021

If you upgrade to the latest Next + @vanilla-extract/next-plugin combo, you should be good now.

3reactions
aquamarinecxcommented, Dec 7, 2021

Specifically next@12.0.5 breaks a variety of packages that I’m using, because they bumped a few dependencies. Downgrading to next@12.0.4 works well

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: options.postcss is not a function This error ... - GitHub
TypeError : options.postcss is not a function This error occurred during the build process and can only be dismissed by fixing the error....
Read more >
TypeError: this.getOptions is not a function - vue.js
I am unsure what to do at this step. Syntax Error: TypeError: this.getOptions is not a function. @ ./node_modules/vue-style-loader??ref-- ...
Read more >
postcss/postcss - Gitter
Hi all I'm getting this error while using postcss-loader. ERROR in ./node_modules/ag-grid-community/dist/styles/ag-theme-fresh.css Module build failed (from ...
Read more >
rollup-plugin-postcss - npm
Start using rollup-plugin-postcss in your project by running `npm i rollup-plugin-postcss`. There are 1426 other projects in the npm ...
Read more >
Handling those unhandled promise rejections with JS async ...
You put your code inside an async function in order to use await calls ... { console.error(e); process.exit(1) })console.log('This will not be printed.');})()....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found