Comments (4)
I created this for a project that uses a custom webpack setup, and not create-react-app
, so I haven't seen the issue you describe. If I manage to find the time, I'll take a look.
from svg-to-json-webpack-plugin.
I think this might have something to do with webpack-dev-server
and not so much create-react-app
. I'm writing the file to my source directory so I can grab specific icons from it with a tiny icon component I created:
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import Icons from './assets/icons/icons.json';
class Icon extends React.Component {
getIcon = () => {
const { icon, className, size, ...opts } = this.props;
const classes = cx('icon', className, {
'icon--small': size === 'small',
'icon--large': size === 'large',
'icon--xlarge': size === 'xlarge',
});
// If we find an icon
if (Icons[icon]) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
strokeLinecap="round"
strokeLinejoin="round"
className={classes}
{...opts}
dangerouslySetInnerHTML={{ __html: [Icons[icon].content] }} // eslint-disable-line react/no-danger
/>
);
}
console.error('Icon not found'); // eslint-disable-line no-console
return false;
}
render() {
return this.getIcon();
}
}
Icon.propTypes = {
className: PropTypes.string,
icon: PropTypes.string.isRequired,
size: PropTypes.oneOf(['small', 'large', 'xlarge']),
};
export default Icon;
but whenever I attempt to call it, the server continues to reload:
from svg-to-json-webpack-plugin.
This looks to be an issue with how Webpack handles watching files that are created within a plugin. Using https://github.com/yessky/webpack-mild-compile resolves the issue. It appears that may be something you can add to your plugin if you wanted to work around the issue yourself webpack/watchpack#25 (comment)
from svg-to-json-webpack-plugin.
Great, glad you found a solution!
from svg-to-json-webpack-plugin.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg-to-json-webpack-plugin.