Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
mior-react-scripts
Advanced tools
基于react-scripts的小改造。
yarn build
时,拷贝public目录里面的内容时会过滤data
文件夹,通常这个里面是放mock数据的。babel-runtime
按需加载,解决不支持es6 7的语法糖,然而如果要解决API层面的,建议自己去引入“core-js”里面的模块。module.exports = {
// 多入口配置
entryList: [
{
name: "index",
path: "index.js",
templatePath: "index.html"
},
{
name: "login",
path: "login.js",
templatePath: "login.html"
},
...
],
// 起别名
alias: {
"Component": path.resolve(__dirname, 'src/component/')
},
eslintRule: {
"globals": {
"$": true
}
},
analyzerWebpack: {
turn: "on", // 关闭的话,属性为off
port: 11111 // 不指定port时,默认为11111
}
}
PORT=3003
myProxy=http://localhost:6002
TITLE=代账宝
{
"dependencies": {
"antd": "^2.7.4",
"axios": "^0.16.1",
"prop-types": "^15.5.10",
"antd-css-rewrite": "^1.0.0",
"babel-runtime": "^6.25.0",
"react-router": "^3.0.2"
}
}
默认react及react-dom是有的
主要用来解决最终项目的URL:http://xxx.com/xxx
,xxx这个目录下,而非http://xxx.com
。
像之前代账宝使用中,webpack.config.prod.js中,有这样的一段配置
{
publicPath: "/dzb"
}
我在这个配置中,未改,那么怎么实现上面的功能呢?很容易(读源码还是需要费点时间的),在package.json中新增homepage
字段:
{
"homepage": "dzb"
}
这样写即可。
在js中可以通过process.env
来取以下变量:
简单说一下URL_PREFIX
。这个需求是这样的:
nginx不配转发,直接URL请求过去。当然这个服务器得配置允许跨域才行。
由于开发环境和build环境的URL_PREFIX是不一样的。所以需要写到package.json中,写法如下:
{
"build": "cross-env URL_PREFIX=http://www.a.com mior-react-scripts build"
}
多个环境就配置多个。。(cross-env,需要自己安装一下,yarn add cross-env -D
)
譬如:
async componentDidMount() {
const {default: Util} = await import("./Util");
console.dir(Util);
}
create-react-app 要创建的目录名称 --scripts-version mior-react-scripts
'react': 'preact-compat',
'react-dom': 'preact-compat',
// Not necessary unless you consume a module using `createClass`
'create-react-class': 'preact-compat/lib/create-react-class'
将这一段拷贝到apps.config.js
的alias中,然后yarn add preact-compat -S
即可。
'react': 'react-lite',
'react-dom': 'react-lite'
将这一段拷贝到apps.config.js
的alias中,然后yarn add react-lite -S
即可。
测试了一下,体积大概能减少至一半。
'react': 'inferno-compat',
'react-dom': 'inferno-compat'
将这一段拷贝到apps.config.js
的alias中,然后yarn add inferno inferno-compat -S
即可。
FAQs
基于react-scripts的小改造,让其支持antd及less
The npm package mior-react-scripts receives a total of 19 weekly downloads. As such, mior-react-scripts popularity was classified as not popular.
We found that mior-react-scripts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.