score:2
so first i had to set an environmental variable in my package.json
file for my start script when i am doing local developement "start": "node_env=local react-app-rewired start",
then in my customizer-cra config-overrides.js
i set my node environmental variable const islocal = process.env.node_env === 'local';
and then i imported the minicssextractplugin plugin from webpack const minicssextractplugin = require('mini-css-extract-plugin');
then i put a ternary to check if the app is running locally where this does not occur or if it is in production where it does occur. the style-loader
was loading the chunk.css file before the compiled less
code in this situation but it could have been sass
also. so i change the code from this:
addwebpackmodulerule({
test: /\.less$/,
use: [
{ loader: 'style-loader'},
{ loader: 'css-loader' },
{ loader: 'less-loader' }
],
}),
to this:
addwebpackmodulerule({
test: /\.less$/,
use: [
{ loader: islocal ? 'style-loader' : minicssextractplugin.loader },
{ loader: 'css-loader' },
{ loader: 'less-loader' }
],
}),
and that fixed the issue.
Source: stackoverflow.com
Related Query
- How to determine the order of css in my create react app build with webpack and customize-cra?
- How can I build a React app with Webpack and import an assets folder?
- I create a build of my react app and connected with electron.js. now how to connect my backend from server folder with electron
- How to import CSS modules with Typescript, React and Webpack
- Why does production build of React app (with Webpack and Babel) use wrong development env with HMR, which causes errors?
- How to analyze create react app build size and reduce it?
- How to read console.log from a mounted component with Enzyme and Jest in Create React App
- How to reduce react app build time and understanding behaviour of webpack when bundling
- How to use Turborepo for an existing react app created with Create React App in order to make it a monorepo?
- how to run my node application and react app in the same time with one command?
- Using LESS CSS with the latest Create React App
- Disable the bundle.js bundling file Webpack creates in React using Create React App or Craco? Or at least get 'Performance' to work with source maps
- Trying to deploy my REACT Webpack app to heroku. Everything works locally and the heroku build works. But I'm getting a 404 nginx
- How to deploy React app with docker and serve -s build
- How create a react app with a specific version using the npx command?
- I am trying to animate an object with css in react and change the animation (timing) dynamically, how can I set the style after animation end?
- Problem with npm build and babel in React Create App
- Build a CRUD App with React Hooks and the Context API
- How do I add WebPack polyfill to React App created with React Create App without ejecting?
- How to Create global styles with Styled components in react and next js and is it better to use combination of css files and styled component?
- How to create multiple swiper instance in a react component and control one with the swipe of another?
- What is the best way to build multi-language app with react and redux?
- Unable to build ES6 version of my React App with webpack and babel-preset-env
- How to create floating image transition with css and react
- How to create a " box with arrow edges in the bottom and placing textinput under the arrow edges" using css
- I am building react app with ag-grid and I am having an issue with trying how to put a link in the cell
- How to create a React app directly in the current folder
- How to test a className with the Jest and React testing library
- What is the difference between NextJs and Create React App
- How to set up Babel 6 stage 0 with React and Webpack
More Query from same tag
- React ProptTypes - object of objects
- React-Table fixed first row
- MaterialUI makeStyles undoes custom css upon refresh in NextJS
- Chakra UI and React | Popover trigger not working
- Rendering comma separated list of links
- How in redux-api-middleware add authentication header
- Dynamic # of states using for loop and setState . Then need to use states after all have been set
- Reactjs with LinkedStateMixin and select with multiple options
- React: Getting runtime error/warning in browser when a component is rendered
- How to fix "Module build failed (from ./node_modules/babel-loader/lib/index.js):"?
- Attempted import error: does not contain a default export
- How to create new elements with React mapping props
- How to return Objects with Object.keys Javascript
- Filter object from array where key "ID" == element.id not working
- Combining React Final Form Array and Final Form Calculate
- Limit the upload number of image in reactjs
- Communication between Django and React
- AWS elastic beanstalk - WARN install EACCES: permission denied, access '/tmp/.npm'
- String as html in reactjs
- How to load table data after submitting the form in react js php
- Redirect ReactJS
- How do I detect when FlatList has rendered all items and actually scrolled to bottom?
- AutoFocus next TextInput onChangeText Crash
- Creating A react component which can be nested
- How to save the position of an element after dragging and changing its position in react js
- Passing arguments to action
- Update Select Option list based on other Select field selection ant design
- Adding webpack config to react-create-app using react-app-rewired
- ReactJS JSX Use Shorthand to Perform Multiple Executions
- How to create range slider? (react-native)