1.dva ์ ์ฑ
2. ๋ค์ ๋ด์ฉ์ผ๋ก ์ webpack.config.js๋ฅผ ๋ง๋ญ๋๋ค.
๊ธฐ๋ณธ ๊ธฐ๋ฅ ๋ด๋ณด๋ด๊ธฐ(webpackConfig) {
webpackConfig.resolve.alias['@babel/runtime'] ์ญ์ ;
webpackConfig๋ฅผ ๋ฐํํฉ๋๋ค.
}
2.npm ์์
๋ธ๋ผ์ฐ์ ๋ ํ์ด์ง๋ฅผ ์ ์์ ์ผ๋ก ํ์ํฉ๋๋ค.
๋ธ๋ผ์ฐ์ ์ฝ์ ์ถ๋ ฅ ๊ฒฝ๊ณ : ์ฌ์ฉํ์ญ์์ค require("history").createHashHistory
๋์ require("history/createHashHistory")
. ํ์์ ๋ํ ์ง์์ ๋ค์ ์ฃผ์ ๋ฆด๋ฆฌ์ค์์ ์ ๊ฑฐ ๋ ์์ ์
๋๋ค
dva-cli ๋ฒ์ 0.10.0
์ฌํ ๊ฐ๋ฅํ ๋จ๊ณ๋ฅผ ์ ๊ณตํ์ญ์์ค.
1.dva ์ ์ฑ
2. ๋ค์ ๋ด์ฉ์ผ๋ก ์ webpack.config.js๋ฅผ ๋ง๋ญ๋๋ค.
๊ธฐ๋ณธ ๊ธฐ๋ฅ ๋ด๋ณด๋ด๊ธฐ(webpackConfig) {
webpackConfig.resolve.alias['@babel/runtime'] ์ญ์ ;
webpackConfig๋ฅผ ๋ฐํํฉ๋๋ค.
}
2.npm ์์
3. ๋ธ๋ผ์ฐ์ ๋ณด๊ธฐ ์ฝ์
ํ๋ index.js : 2177 ๊ฒฝ๊ณ : ์ฌ์ฉํ์ญ์์ค require("history").createHashHistory
๋์ require("history/createHashHistory")
ํ์์ ๋ํ ์ง์์ ๋ค์ ์ฃผ์ ๋ฆด๋ฆฌ์ค์์ ์ ๊ฑฐ ๋ ์์ ์
๋๋ค..
๊ฒฝ๊ณ ์ ๋ณด๋ ๋ฌด์๋๋ฉฐ ์ฌ์ฉ์ ์ํฅ์ ๋ฏธ์น์ง ์์ผ๋ฉฐ ๋ค์ ๋ฒ์ ์์ ํด๊ฒฐ๋ ์์ ์ ๋๋ค.
1.dva ์ ์ฑ
2. ๋ค์ ๋ด์ฉ์ผ๋ก ์ webpack.config.js๋ฅผ ๋ง๋ญ๋๋ค.
๊ธฐ๋ณธ ๊ธฐ๋ฅ ๋ด๋ณด๋ด๊ธฐ(webpackConfig) {
webpackConfig.resolve.alias['@babel/runtime'] ์ญ์ ;
webpackConfig๋ฅผ ๋ฐํํฉ๋๋ค.
}
2.npm ์์
3. ๋ธ๋ผ์ฐ์ ๋ณด๊ธฐ ์ฝ์ํ๋ index.js : 2177 ๊ฒฝ๊ณ : ์ฌ์ฉํ์ญ์์ค
require("history").createHashHistory
๋์require("history/createHashHistory")
ํ์์ ๋ํ ์ง์์ ๋ค์ ์ฃผ์ ๋ฆด๋ฆฌ์ค์์ ์ ๊ฑฐ ๋ ์์ ์ ๋๋ค..
1.dva ์ ์ฑ
2. ๋ค์ ๋ด์ฉ์ผ๋ก ์ webpack.config.js๋ฅผ ๋ง๋ญ๋๋ค.
๊ธฐ๋ณธ ๊ธฐ๋ฅ ๋ด๋ณด๋ด๊ธฐ(webpackConfig) {
webpackConfig.resolve.alias['@babel/runtime'] ์ญ์ ;
webpackConfig๋ฅผ ๋ฐํํฉ๋๋ค.
}
2.npm ์์
3. ๋ธ๋ผ์ฐ์ ๋ณด๊ธฐ ์ฝ์ํ๋ index.js : 2177 ๊ฒฝ๊ณ : ์ฌ์ฉํ์ญ์์ค
require("history").createHashHistory
๋์require("history/createHashHistory")
ํ์์ ๋ํ ์ง์์ ๋ค์ ์ฃผ์ ๋ฆด๋ฆฌ์ค์์ ์ ๊ฑฐ ๋ ์์ ์ ๋๋ค..
์ด ๋ฌธ์ ๋ ์ด๋ป๊ฒ ํด๊ฒฐ๋ฉ๋๊น?๋์์ ์์ฒญ
@mystylemylife ๋ ์ฌํ ๋จ๊ณ๋ฅผ ์ ๊ณตํฉ๋๋ค. .
@mystylemylife ๋ ์ฌํ ๋จ๊ณ๋ฅผ ์ ๊ณตํฉ๋๋ค. .
@mystylemylife ๋ ์ฌํ ๋จ๊ณ๋ฅผ ์ ๊ณตํฉ๋๋ค. .
[email protected] ์ ์์ํ ๋ @bestXie ์ ๋ฐฉ๋ฒ
๊ธฐ์กด ํ๋ก์ ํธ์์ nodemodule์ ๋ค์ ์ค์นํ๊ณ ์ค๋ฅ๋ฅผ ๋ณด๊ณ ํ์ต๋๋ค. [email protected]์ ๋ฌธ์ ๋ฅผ ๋ณด์ญ์์ค. <br i="5"/> ์๋ณธ ํฌ์คํฐ์ ๊ฐ์ด
๊ธฐ์กด ํ๋ก์ ํธ์์ nodemodule์ ์ฌ์ค์นํ๊ณ ์ค๋ฅ๋ฅผ ๋ณด๊ณ ํ์ต๋๋ค. ์๋ณธ ํฌ์คํฐ์ ๋ง์ฐฌ๊ฐ์ง๋ก [email protected]<br i="6"/> Update
๋ก๋ํธ๊ทธ ๋ฒ์ ์ 2.5.0-beta.4๋ก ์ ๊ทธ๋ ์ด๋ํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
import { createBrowserHistory } from 'history' ๆimport { createHashHistory } from 'history'
์ด์ ๋ช ๊ฐ์์ด ์ง๋ฌ์ต๋๋ค. ์ ๋ง ๋๋์ ์ ๋๋ค.
์ด์ ํ๋ก์ ํธ์์ nodemodule์ ๋ค์ ์ค์นํ๊ณ ์ค๋ฅ๋ฅผ ๋ณด๊ณ ํ์ต๋๋ค. [email protected]<br i="7"/> Update
๋ก๋ํธ๊ทธ ๋ฒ์ ์ 2.5.0-beta.4๋ก ์ ๊ทธ๋ ์ด๋ํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
์ด ๋ฌธ์ ๋ ๋ก๋ํธ๊ทธ ๋ฒ์ ์ 2.5.0-beta.4๋ก ์ ๊ทธ๋ ์ด๋ํ ๋๋ ๋ฐ์ํฉ๋๋ค.
ํด๊ฒฐํ๋ค:
dva
ํด๋์ ์๋ node_modules
์์ lib/index.js
์์ ํฉ๋๋ค.var _createHashHistory = _interopRequireDefault(require("history/createHashHistory"));
var _createHashHistory = _interopRequireDefault(require("history").createHashHistory);
์ปดํ์ผ๋ฌ๋ฅผ ์ ์ฅํ๊ณ ๋ซ๊ณ ์๋น์ค๋ฅผ ๋ค์ ์์ํ์ญ์์ค.
dva๊ฐ ๊ด๋ฆฌ๋์ง ์๋ ๋๋์ด ๋๋์?์ด ๋ฌธ์ ๋ ์ฌ์ ํ ๋๋ฌด ์ค๋ซ๋์ ์กด์ฌํฉ๋๋ค. ์ ๋ซํ์ต๋๊น?
ํ๋ก์ ๊ธฐ๋ณธ console.warn ๋ฐ console.error๋ก ํด๊ฒฐ
(() => {
//่ฟๆปคๆไธไบๆ ็จ็่ญฆๅใๆฒกๆไปทๅผ็ๆฅ้
//ไปฃ็console.warnๆนๆณ
const _consoleWarn = console.warn;
console.warn = (...rest) => {
if (
![
'react-error-overlay is not meant for use in production. You should ensure it is not included in your build to reduce bundle size.',
'Warning: componentWillReceiveProps has been renamed',
'Warning: componentWillUpdate has been renamed',
].some((item) => rest[0].indexOf(item) !== -1)
) {
_consoleWarn(...rest);
}
};
//ไปฃ็console.error
const _consoleError = console.error;
console.error = (...rest) => {
if (
![
`Warning: Please use \`require("history").createHashHistory\` instead of \`require("history/createHashHistory")\`. Support for the latter will be removed in the next major release.`,
'ui socket init',
].includes(rest[0].toString())
) {
_consoleError(...rest);
}
};
})();
์์ํ๊ธฐ ์ ์ ๋งค๋ฒ ํจ์น๋ฅผ ์์ฑํ์ต๋๋ค. ./node_modules/dva/lib/index.js
require\\("history/createHashHistory"\\)
๋ฅผ require("history").createHashHistory
๋ฐ๊พธ์ญ์์ค.
patch.js
ํ์ผ์ ์ถ๊ฐํ๋ฉด ๋ด์ฉ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.const replace = require("replace");
replace({
regex: 'require\\("history/createHashHistory"\\)',
replacement: 'require("history").createHashHistory',
paths: ['./node_modules/dva/lib/index.js'],
recursive: true,
silent: true,
});
package.json
์ฆ๊ฐ์์ start
๋ช
๋ น ์์ npm run patch &&
์ฆ๊ฐ, "patch": "node ./patch.js"
npm
๋ช
๋ น:{
...
"scripts": {
"start": "npm run patch && cross-env APP_TYPE=site umi dev", // startๅฝไปคไนๅๅ
่ฟ่กpatch.js
...
"patch": "node ./patch.js"
},
...
}
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
dva๊ฐ ๊ด๋ฆฌ๋์ง ์๋ ๋๋์ด ๋๋์?์ด ๋ฌธ์ ๋ ์ฌ์ ํ ๋๋ฌด ์ค๋ซ๋์ ์กด์ฌํฉ๋๋ค. ์ ๋ซํ์ต๋๊น?