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

Facing css import issue in create react app in typescript #300

Closed
ghost opened this issue Mar 27, 2020 · 14 comments
Closed

Facing css import issue in create react app in typescript #300

ghost opened this issue Mar 27, 2020 · 14 comments
Milestone

Comments

@ghost
Copy link

ghost commented Mar 27, 2020

I am facing css import issue in create react app in typescript

Can u please let me know how I can resolve this issue as I have imported the css into my typescript file as below

import 'suneditor/dist/css/suneditor.min.css';

image

@JiHong88
Copy link
Owner

Which version are you using?

@ghost
Copy link
Author

ghost commented Mar 27, 2020

[email protected]

@ghost
Copy link
Author

ghost commented Mar 27, 2020

I have added the path of the suneditor.min.css in CopyWebpackPlugin in Webpack
as node_modules/suneditor/dist/css/suneditor.min.css
And in
new HtmlWebpackIncludeAssetsPlugin({
assets: [
'css/suneditor.min.css'] })

And use in my typescript file as

import 'suneditor/dist/css/suneditor.min.css';

It works in my dev env but fails in Prod after build as shown in figure above

@JiHong88
Copy link
Owner

JiHong88 commented Mar 27, 2020

It seems that the web font is not loaded.
You must have a file loader.
Web fonts may not be loaded depending on the environment settings.
The latest version uses "inline svg" rather than a web font.
Please update the editor to the latest version.

@JiHong88 JiHong88 reopened this Mar 27, 2020
@ghost
Copy link
Author

ghost commented Mar 27, 2020

ok how do I use font import in CopyWebpackPlugin

@JiHong88
Copy link
Owner

Sorry, I don't know..😭
I recommend updating the version.

@JiHong88
Copy link
Owner

I set it like this in my webpack environment.

{
	test: /\.(eot|svg|ttf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
	use: [{
		loader: "file-loader",
		options: {
			publicPath: '../',
			name: 'fonts/[hash].[ext]',
			limit: 5000,
			mimetype: 'application/font-woff'
		}
	}]
}

Even if the web font is loaded with this setting, it is recommended to use the latest version.

@ghost
Copy link
Author

ghost commented Mar 27, 2020

Can u let me know what is the improvement in switching to newer version

@JiHong88
Copy link
Owner

Please refer to the release history.
https://github.com/JiHong88/SunEditor/releases

@rwaldron
Copy link
Contributor

rwaldron commented Jun 1, 2020

I was experiencing similar issues, as I have

import 'suneditor/dist/css/suneditor.min.css';

...in my code as well.

Here's what I've learned: in development mode, webpack is just copying the contents of that file and putting it into a <style> element, without interacting with the source. In production mode, webpack will open the source, copy the contents into memory and attempt to minify it with Terser, however there must be a syntax error in 'suneditor/dist/css/suneditor.min.css', because it fails to parse and therefore fails to include it in the final production bundle. There is also evidence that 'suneditor/dist/css/suneditor.min.css' has a syntax error, because my text editor cannot apply css syntax highlighting to it. I will report back if I can find more information.

@rwaldron
Copy link
Contributor

rwaldron commented Jun 1, 2020

According to csslint.com: Expected RBRACE at line 1, col 30372..

Edit: this may be due to csslint not supporting custom properties.

@rwaldron
Copy link
Contributor

rwaldron commented Jun 1, 2020

I think both my CSS syntax highlighter, Terser and CSS Lint don't understand the 1turn value here:

@keyframes spinner{
  to {
    transform: rotate(1turn);
  }
}

When I change it to:

@keyframes spinner{
  to {
    transform: rotate(360deg);
  }
}

CSS Lint is happy.

@JiHong88
Copy link
Owner

JiHong88 commented Jun 2, 2020

@rwaldron Thank for your feedback!
I have checked this issue, and it seems that "cssnano" converts "360deg" to "1turn".

cssnano/cssnano#823
This issue does not seem to be resolved. :(
I will fix this issue by changing "360deg" to "361deg". ea233b7

@JiHong88 JiHong88 added this to the 2.30.0 milestone Jun 2, 2020
@JiHong88
Copy link
Owner

JiHong88 commented Jun 9, 2020

The 2.30.0 version has been updated.
If this issue has not been resolved, please reopen this issue.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants