If you're using styled components and keep getting errors in development mode use the settings below to fix
Create a .babelrc file in your root folder and add the following:
{ "presets": [ "next/babel" ], "plugins": [ [ "styled-components", { "ssr": true } ] ] }
Related
I have a Wordpress project where Webpack and the StyleLint plugin are being used.
The problem is when compiling sass, it shows this error where it says it doesn't recognize the 'aspect-ratio' property that I'm using in my styles:
Unexpected unknown property "aspect-ratio" property-no-unknown
I tried adding 'ignoreProperties' to the config in the .stylelintrc.js file but it didn't work and it kept showing the error.
module.exports = {
'extends': 'stylelint-config-standard',
'rules': {
'no-empty-source': null,
'string-quotes': 'double',
'at-rule-no-unknown': [
true,
{
'ignoreProperties': [
'aspect-ratio'
]
},
{
'ignoreAtRules': [
'extend',
'at-root',
],
},
],
},
};
How could I fix it? (I'm not very knowledgeable in StyleLint and this project was started by someone else.)
aspect-ratio is a known property in the latest version of Stylelint. You should update your copy of Stylelint to the latest version using:
npm install -D stylelint#latest
Alternatively, you can use the ignoreProperties secondary option, but you should use it on the property-no-unknown rule rather than the at-rule-no-unknown one as it's a property, not an at-rule:
module.exports = {
'extends': 'stylelint-config-standard',
'rules': {
'no-empty-source': null,
'string-quotes': 'double',
'at-rule-no-unknown': [
true,
{
'ignoreAtRules': [
'extend',
'at-root',
],
},
],
},
'property-no-unknown': [
true,
{
'ignoreProperties': [
'aspect-ratio'
]
},
]
};
Using React-bootstrap in our NextJS (10.0.0) app and need to remove unused CSS so using purgecss for that. But all the CSS are getting removed after doing like in this https://purgecss.com/guides/next.html. And found that issue is because of CSS Modules that we are using.
Here is my postcss.config.js
module.exports = {
"plugins": [
"postcss-flexbugs-fixes",
[
"postcss-preset-env",
{
"autoprefixer": {
"flexbox": "no-2009"
},
"stage": 3,
"features": {
"custom-properties": false
}
}
],
[
'#fullhuman/postcss-purgecss',
{
content: [
'./pages/**/*.{js,jsx,ts,tsx}',
'./components/**/*.{js,jsx,ts,tsx}'
],
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
safelist: ["html", "body"]
}
],
]
}
Any ways to remove unused CSS?
I just updated Babel6 to Babel7 with all of the necessary packages but can't resolve how to make babel.config.js correctly getting one or another error depending on the specified Babel7 plugins. Here is how my babel.config.js looks like:
module.exports = {
"env": {
"test": {
"presets": [
"#babel/preset-env",
"#babel/preset-react"
],
"plugins": [
"#babel/plugin-proposal-class-properties",
"#babel/plugin-transform-modules-commonjs",
"#babel/plugin-syntax-dynamic-import",
"babel-plugin-dynamic-import-node",
"#babel/plugin-proposal-export-default-from"
]
}
},
"plugins": [
"#babel/plugin-transform-modules-commonjs",
"#babel/plugin-proposal-export-default-from",
"babel-plugin-dynamic-import-node",
"#babel/plugin-transform-runtime",
"#babel/plugin-transform-regenerator",
"#babel/plugin-syntax-dynamic-import",
[
"#babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"#babel/plugin-proposal-object-rest-spread",
"#babel/plugin-proposal-class-properties",
[
"babel-plugin-styled-components",
{
"displayName": true
}
],
[
"babel-plugin-module-resolver",
{
"root": [
"./"
],
"extensions": [
".js",
".jsx",
".css"
],
"alias": {
"shared": "./shared/",
"pages": "./pages/",
"gtex-d3": "./node_modules/gtex-d3/"
}
}
]
],
"presets": [
"#babel/preset-react",
[
"#babel/preset-env",
{
"modules": false
}
]
]
}
So, with such configs I am getting the error:
TypeError: (0 , _typeof2.default) is not a function
Here I found a probable solution:
https://github.com/zeit/next.js/issues/6879
Remove "#babel/preset-env". So, after removing it I am getting an error in one of the node_modules package (which may mean that #babel/preset-env is needed to avoid that...):
./node_modules/igv/dist/igv.esm.js
Module build failed: TypeError: /Users/vlasenkona/Desktop/gris-seqr2/ui/node_modules/igv/dist/igv.esm.js: Property name expected type of string but got null
at Array.forEach ()
If I remove "#babel/plugin-transform-modules-commonjs" instead I will get another error:
./node_modules/semantic-ui-react/dist/es/modules/Dropdown/Dropdown.js
1002:14-23 "export 'default' (imported as 'PropTypes') was not found in 'prop-types'
Which is happening because the removed #babel/plugin-transform-modules-commonjs is needed for that. So, from these 3 errors it seems to me that the second should be fixed and there is a thread:
https://github.com/alanbsmith/babel-plugin-react-add-property/issues/3
And it is not solved, so I am stuck. Any suggestions would be greatly appreciated.
npm install --save-dev #babel/plugin-transform-destructuring
. babelrc
{ "plugins": [ ["#babel/plugin-transform-destructuring", { "useBuiltIns": true }] ] }
I've been trying to add a custom CSS file to the final build from Sencha CMD on ExtJS Application. The application has been generated using the CMD.
My CSS file is located in resources/Custom/myfile.css
try to do many different approach that i found but with no success.
My app.json looks like
{
"builds": {
"production": {
"default": true,
"compressor": {
"type": "closure"
}
}
},
"name": "Test.App",
"css": [
{
"path": "resources/Custom/_body.css",
"remote": true
}
],
"requires": [
],
"id": "fb0cc613-c7e3-4e2e-9f9f-aa569fcf2465"
}
But when try to build i got the error:
BUILD FAILED
[ERR] com.sencha.exceptions.ExBuild: Combining x-compile in HTML page with Microloader in app.json is not supported
If i remove the CSS part fo the app.json it does work !!!
I am using ExtJS 4.1.1
Any Help?
So I followed the instructions at guide.meteor.com to set up my package.json eslintConfig.
"eslintConfig": {
"plugins": [
"meteor"
],
"extends": [
"airbnb/base",
"plugin:meteor/recommended"
],
"rules": {
"meteor/eventmap-params": [
2,
{
"templateInstanceParamName": "instance"
}
],
"import/no-unresolved": [
2,
{
"ignore": [
"^meteor/"
]
}
],
"semi": [
"error",
"never"
]
}
}
It works fine until I try and use React.
main.js:
Meteor.startup(() => {
render(<App />, document.getElementById('render-target'))
})
That throws the error: [eslint] Parsing error: Unexpected token <
I have the react plugin:
"devDependencies": {
"eslint": "^2.9.0",
"eslint-config-airbnb": "^8.0.0",
"eslint-plugin-import": "^1.6.1",
"eslint-plugin-jsx-a11y": "^1.0.4",
"eslint-plugin-meteor": "^3.5.2",
"eslint-plugin-react": "^5.0.1"
}
I've tried following examples from Google but none of them helped. I've tried adding 'react' and 'eslint-plugin-react' to the plugins bit and nothing changed. I'm gobsmacked the solution wasn't provided in the ESLint section of the meteor guide. Any assistance would be appreciated.
Install babel-eslint and to your .eslintrc add "parser": "babel-eslint". You're missing the ES6 transpiling so eslint just crashes.
You don't need to install babel-eslint. Espree (native ESLint parser) fully supports ES6, ES7 and Object Rest/Spread.
The reason ESLint stopped parsing your file is because you haven't enabled jsx, so it will consider it as an incorrect syntax.
{
"ecmaFeatures": {
"ecmaVersion": 6,
"sourceType": "module",
"jsx": true
}
}
Add the above snippet to your config file and it should start working. For more information, you can read Specifying Parser Options