
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
bcd-react-webpack
Advanced tools
Use webpack painless.
npm install --save-dev webpack webpack-cli webpack-dev-server bcd-react-webpack
{
"scripts": {
"start": "webpack-dev-server --hot",
"build": "NODE_ENV=production webpack"
}
}
create webpack config file webpack.config.js
const createConfig = require('bcd-react-webpack');
const env = process.env.NODE_ENV || 'development';
module.exports = createConfig({
publicPath: env === 'development' ? '/' :
// TODO: online assets url prefix, you should modify this
'https://lesspage.oss-cn-shanghai.aliyuncs.com/'
});
npm install --dev node-sass sass-loader
tsconfig.js{
"compilerOptions": {
"module": "commonjs",
"sourceMap": true,
"esModuleInterop": true,
"target": "ES2020",
"jsx": "react"
}
}
npm install -D @types/react @types/react-dom @types/prop-types
- config/
- webpack.config.js
- src/
- template.html # tempalte file for HtmlWebpackPlugin
- pages/ # deduce webpack entries from pages dir
- index/
- index.js
- design/ # muti entry support
- index.js
- index.html # custom template
- components/ # arbitrarily dir/packages。
- utils/
- package.json
We also alias '@' for src dir.
import Avatar from '@/components/Avatar';
// import Avatar from '../../../../components/Avatar';
Muti entry pages may slowdown the building in current webpack-dev-server,
use arg --stage for only build specify entry page.
You can also config stage in config for forcing specify this arg in dev and build phase.
module.exports = createConfig({
...,
stage: true
});
{
"scripts": {
"start": "webpack-dev-server --hot --config config/webpack.config.js"
}
}
npm run start --stage mypage
module.exports = createConfig({
publicPath: env === 'development' ? '/' : './',
devServer: { ... }, // @see https://webpack.js.org/configuration/dev-server/
shouldUseSourceMap: true, // use 'source-map', current default use 'cheap-module-source-map'
extractCss: true,
srcPath: 'src', // source dir
distPath: 'dist', // output dir
assetsDir: { js: 'js/', css: 'css/', media: 'media/' }, // output assets dir
pagesPath: 'pages',
digest: false, // in production env, default to true
swPrecache: false, // disable SWPrecacheWebpackPlugin
manifest: false, // disable manifest file
manifest: { fileName }, // custom manifest filename
bundleAnalyzer: false, // disable analyzer plugin
});
FAQs
create webpack config for react application
We found that bcd-react-webpack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.