This is a small react project demo. It includs router, redux, less, model the most common parts in React.
# Install dependencies for server
npm install
# Run the React client
npm start
# Server runs on http://localhost:3000
You will need to modify webpack.config.dev.js and webpack.config.prod.js which are under route 'node_modules\react-scripts\config'.
You can use search function to find the location of these points in webpack.config.dev.js and webpack.config.prod.js.
#point 1: add @ as default src route
alias: {
'@': path.resolve('src'), // add this line in alias
'react-native': 'react-native-web',
},
#point 2: use .(css|less) replace .css in the following lines
const cssRegex = /\.(css|less)$/;
const cssModuleRegex = /\.module\.(css|less)$/;
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/, /\.(css|less)$/],
#point 3: add less-loader in const loaders
const getStyleLoaders = (cssOptions, preProcessor) => {
const loaders = [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: cssOptions,
},
{ //add this line
loader: require.resolve('less-loader'), //add this line
options: cssOptions, //add this line
}, //add this line
Bo Long
1.0.0
This project is licensed under the MIT License