javascript - How to set up Stylelint in a Next.js project? - Stack Overflow

I want to add Stylelint to my Next.js app. I am asking if I can edit next.config.js to add stylelint-we

I want to add Stylelint to my Next.js app. I am asking if I can edit next.config.js to add stylelint-webpack-plugin, so I get styles errors during pilation.

// next.config.js
module.exports = {
  reactStrictMode: true,
};

I want to add Stylelint to my Next.js app. I am asking if I can edit next.config.js to add stylelint-webpack-plugin, so I get styles errors during pilation.

// next.config.js
module.exports = {
  reactStrictMode: true,
};
Share Improve this question edited Oct 15, 2022 at 7:30 Youssouf Oumar asked Nov 30, 2021 at 3:56 Youssouf OumarYoussouf Oumar 46.6k16 gold badges103 silver badges105 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Prepare the setup for both CSS and SCSS

  1. Install needed packages:
npm i stylelint stylelint-webpack-plugin --save-dev
  1. Create a .stylelintignore file in your root folder et past in it:
node_modules
  1. Edit the next.config.js file:
const StylelintPlugin = require("stylelint-webpack-plugin"); // line to add
module.exports = {
  reactStrictMode: true,
  // lines to add
  webpack: (config, options) => {
    config.plugins.push(new StylelintPlugin());
    return config;
  },

};

Set up Stylelint with CSS

  1. Install the needed package:
npm i stylelint-config-standard --save-dev
  1. Create a .stylelintrc file in your root folder and past in it:
{
 "extends": "stylelint-config-standard",
 "rules": {
   "string-quotes": "double"
  }
}

Set up Stylelint with SCSS

  1. Install needed packages:
npm i sass stylelint-config-standard-scss --save-dev
  1. Create a .stylelintrc file in your root folder and past in it:
{
 "extends": "stylelint-config-standard-scss",
 "rules": {
   "string-quotes": "double"
  }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745318367a4622324.html

相关推荐

  • javascript - How to set up Stylelint in a Next.js project? - Stack Overflow

    I want to add Stylelint to my Next.js app. I am asking if I can edit next.config.js to add stylelint-we

    9小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信