I'm building a React app that has progress bars from Bootstrap.
<div className="progress">
<div className="progress-bar"
role="progressbar"
aria-valuenow="60"
aria-valuemin="0"
aria-valuemax="100"
style={{ width: "60%" }}
/>
</div>
and CSS
.progress {
height: 5px;
background-color: #9c9c9c; }
.progress-bar {
height: 5px;
background-color: blue;
animation: animated-progress 3s ease-out; }
@keyframes animated-progress {
from {
width: 0; }
to {
width: calc(width); } }
This is the complete code in codesandbox
I got the idea of using calc(width) to get element's width from this StackOverflow answer
It's working fine during development. However, when I run the command npm run build for production, I got the following error
Lexical error on line 1: Unrecognized text.
Erroneous area:
1: width
^..^
CompileError: Begins at CSS selector undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
I know this error is caused by calc(width), because I was able to build if I changed from calc(width) to calc(60%). As you may realize, doing something like calc(60%) is not a good approach to hard code the width.
