1 Star 0 Fork 6

诺归 / geek-pc-sh88

forked from flycc258 / geek-pc-sh88 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
craco.config.js 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
flycc258 提交于 2021-11-17 17:25 . 打包-增加了反向代理
const path = require('path')
// HtmlWebpackPlugin
const { whenProd, getPlugin, pluginByName } = require('@craco/craco')
module.exports = {
webpack: {
alias: {
'@': path.join(__dirname, 'src')
},
configure: (webpackConfig) => {
let cdn = {
js: [],
css: []
}
// 对webpack进行配置
whenProd(() => {
// 只会在生产环境执行
webpackConfig.externals = {
react: 'React',
'react-dom': 'ReactDOM',
redux: 'Redux',
'react-router-dom': 'ReactRouterDOM'
}
cdn = {
js: [
'https://cdn.bootcdn.net/ajax/libs/react/17.0.2/umd/react.production.min.js',
'https://cdn.bootcdn.net/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js',
'https://cdn.bootcdn.net/ajax/libs/redux/4.1.0/redux.min.js',
'https://cdn.bootcdn.net/ajax/libs/react-router-dom/5.2.0/react-router-dom.min.js'
],
css: []
}
})
const { isFound, match } = getPlugin(
webpackConfig,
pluginByName('HtmlWebpackPlugin')
)
if (isFound) {
// 找到了html的插件
match.options.cdn = cdn
}
return webpackConfig
}
},
devServer: {
proxy: {
'/api': {
target: 'http://geek.itheima.net/v1_0/',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
}
}
}
1
https://gitee.com/nuogui/geek-pc-sh88.git
git@gitee.com:nuogui/geek-pc-sh88.git
nuogui
geek-pc-sh88
geek-pc-sh88
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891