μμ© νλ‘κ·Έλ¨μ λ€μκ³Ό κ°μ κ΅¬μ‘°κ° μμ΅λλ€.
λλ 머리μ index.htmlμ μ΄λ€.
<link rel="stylesheet" href="css/app.css"/>
μ μλ₯Ό μ€ννκ³ μ€λ₯κ° λ°μν©λλ€.
리μμ€ λ‘λ μ€ν¨: net::ERR_FILE_NOT_FOUND file:///D:/css/app.css
λͺ¨λλ€ λ§ν΄μ£ΌμΈμ. νμΌμ κ²½λ‘λ₯Ό μ΄λ»κ² μ€μ ν΄μΌ νλμ?
κ΄λ ¨ λ¬Έμ : #1747.
μ΄ κ²½λ‘ λ¬Έμ λ₯Ό ν΄κ²°νλ λ€λ₯Έ λ°©λ²μΌλ‘ μ΄κ²μ μλνμμμ€.
<html>
<head>
<title></title>
</head>
<body>
<script>
var link = document.createElement('link')
link.setAttribute('rel', 'stylesheet')
link.setAttribute('href', require('path').join(__dirname, 'css', 'app.css'))
document.head.appendChild(link)
</script>
</body>
</html>
@shama μ€λν« κ°μ¬ν©λλ€.
μ΄ μ€λ₯κ° μμΌλ©΄ <base href="/">λ₯Ό μ¬μ©νκΈ° λλ¬Έμ μ€λ₯κ° λ°μν©λλ€.
μν μμ
https://github.com/RinatMullayanov/angular-boilerplate λΆκΈ° μ μ .
κ°μ λ¬Έμ λ μμ΅λλ€. Electronμ C:/ μμ 리μμ€λ₯Ό λ‘λνλ €κ³ νλ©° μλ κ²½λ‘κ° μλνμ§ μμ΅λλ€.
μ 체 κ²½λ‘ μ€μ μ μ΅μ
μ΄ μλλ©° λ€λ₯Έ κ²½λ‘μ μμ© νλ‘κ·Έλ¨μ λ°°μΉνλ©΄ νμΌμ΄ λ‘λλμ§ μμ΅λλ€.
μΌλΆ κΈκΌ΄μ μ»λ κ²κ³Ό λμΌν λ¬Έμ κ° μμ΅λλ€.
λ΄ CSSμ μ΄κ²μ μΆκ°νμ΅λλ€.
<strong i="7">@import</strong> url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);
λλ μ΄κ²μ λ΄ htmlμ μΆκ°νλ €κ³ μλνμ΅λλ€.
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
λλ λν μλνλ€ :
<link rel="stylesheet" type="text/css" href="http//fonts.googleapis.com/css?family=Open+Sans" />
<link rel="stylesheet" type="text/css" href="https//fonts.googleapis.com/css?family=Open+Sans" />
νμ§λ§μ΄ μ€λ₯κ° λ°μν©λλ€.
Failed to load resource: net::ERR_CONNECTION_REFUSED
νμνλ©΄μ΄ λ¬Έμ κ° λ°μν κ²½μ° <base href="/">
λ index.htmlμ λΆκ³Όνμ¬ κ΅μ²΄ <base href="./">
.
@Myrga λΉμ μ μλͺ μ ꡬνμ΅λλ€. λλμ΄ μ€λλ κ²μλ¬Όμ λ°κ²¬ ν λκΉμ§ 5 μΌ λμ λ΅λ³μ μ°Ύκ³ μμκ³ μ΄μ λν λ¬Έμλ μμ΅λλ€. μ λ§ κ°μ¬ν©λλ€
ps: μ¬κΈ° μμ create-react-appμ μ¬μ©νκ³ μλ€λ©΄ package.jsonμ "homepage": "./",
λ₯Ό λ£μ΄λ³΄μΈμ. (λΆλͺ
ν μ΄κ²μ νμ¬ μ§μλμ§ μμΌλ―λ‘ κΈκΌ΄ λ±μ λ€λ₯Έ λ¬Έμ κ° μμ μ μμΌλ―λ‘ ν΄λΉ μμ°μ /public ν΄λλ‘ μ΄λν΄μΌ ν μ μμ)
λ§€μ° κ°μ¬ν©λλ€
@BesatZardosht URLμ μ€νκ° μμ΅λλ€.
<link rel="stylesheet" type="text/css" href="https//fonts.googleapis.com/css?family=Open+Sans" />
ν΄μΌνλ€:
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans" />
( :
)
Webpack 2.x
, React
λ°/λλ Redux
μ¬μ©νμ¬ λμΌν λ¬Έμ κ° μλ κ²½μ° μ΄κ²μ΄ λ¬Έμ λ₯Ό ν΄κ²°ν κ°λ₯μ±μ΄ μμ΅λλ€.
νλ‘μ νΈ λλ ν 리μμ "publicPath"λ₯Ό κ²μνκ³ κ°μ
/
μμ./
λͺ¨λ μ¬μ© κ°λ₯ν λ€λ₯Έ boilerplatesμΌλ‘μ΄ μ€μ μ λ΄ κ²½μ° μ¬μ©μμ, μλ‘ λ€λ₯Έ μμΉμμ μ°Ύμ μμλ€redux-cli
μ¬μ©νλμredux-starter-kit
, κ·Έκ²μμ΄μλ€project.config.js
:
publicPath: './',
λν Electron
μ©μΌλ‘ λΉλνλ κ²½μ° Webpack target
μμ±μ μΆκ°/μμ ν΄μΌ ν μλ μμ΅λλ€.
ν볡νμΈμ!! π
κ°μ λ¬Έμ κ° μμμ§λ§ Myrgaμ μ루μ
μ΄ ν¨κ³Όκ° μμμ΅λλ€. μ μκ°μλ
Reactμμ λ΄ μ ν리μΌμ΄μ μ λ€μ λ§λ€κΈ°λ‘ κ²°μ νμ΅λλ€. λ΄ νλ‘μ νΈμ νμΌ λ‘λλ₯Ό μΆκ°νλ©΄ μ΄ λ¬Έμ κ° λ€μ λ°μνκΈ° μμνμ΅λλ€. webpack.config.jsμ publicPath μμ±μ μλ κ²½λ‘(μ μ κ²½μ° /app/κ° μλ ./app/)λ‘ λ³κ²½νλ©΄ λ¬Έμ κ° ν΄κ²°λμμ΅λλ€.
PSλ κ°λ°μ μλ²κ° μ΄κ²μ μ«μ΄νλ κ² κ°μ΅λλ€. μ΄ λ³κ²½μ μννκ³ webpack dev μλ²λ₯Ό μ€ννλ €λ κ²½μ° μ΄ λ³κ²½μΌλ‘ μΈν΄ νΌλλ κ²μ λλ€. μ μμμ μ§μ μμ νκ³ dev μλ²μμ μμ ν λ μλ€λ‘ μ νν΄μΌ ν©λλ€.
html νμΌμ "μΉ νμ΄μ§λ‘ μ μ₯"μΌλ‘ μ μ₯ν λ€μ ν¬λ‘¬μμ μ΄μ΄λ³Ό μ μμ΅λλ€.
μ΄κ²μ λλ₯Ό μν΄ μΌνμ΅λλ€.
" μμμ λ‘λνμ§ λͺ»νμ΅λλ€: net::ERR_FILE_NOT_FOUND "λ₯Ό ν΄κ²°νλ λ°©λ²
"CSS"λ₯Ό μ¬μ©νμ¬ μ΄λ―Έμ§λ₯Ό μΆκ°ν λλ§λ€ μ΄ μ€λ₯κ° λ°μν©λλ€. νΉμ ν΄κ²° λ°©λ² μμΌμ κ°μ???
μ΄λ―Έμ§λΏλ§ μλλΌ κΈκΌ΄ νμΌκ³Ό κ°μ νμΌμμλ λμΌν μ€λ₯κ° λ°μν©λλ€.
@sunsun_sssssss @sssssssssss
λͺ¨λ νμΌμ΄ μλ μ± κ²½λ‘κ° μλ λ‘컬 νμΌ μμ€ν
μμ μ 곡λκΈ° λλ¬Έμ
λλ€.
ν΄κ²°μ±
μ νμΌ νλ‘ν μ½μ κ°λ‘μ±λ κ²μ
λλ€. main.js νμΌμμ λ€μ λ³κ²½μ μννμμμ€.
mainWindow = new BrowserWindow({width: 1100, height: 700, icon: __dirname + '/icon.ico'})
mainWindow.loadURL(url.format({
pathname:'index.html',
protocol: 'file',
slashes: true
}))
app.on('ready', () => {
protocol.interceptFileProtocol('file', (request, callback) => {
const url = request.url.substr(7) /* all urls start with 'file://' */
callback({ path: path.normalize(
${__dirname}/${url} )})
}, (err) => {
if (err) console.error('Failed to register protocol')
})
createWindow() /* callback function */
})
NS
@sunsun_sssssss @sssssssssss
λͺ¨λ νμΌμ΄ μλ μ± κ²½λ‘κ° μλ λ‘컬 νμΌ μμ€ν μμ μ 곡λκΈ° λλ¬Έμ λλ€.
ν΄κ²°μ± μ νμΌ νλ‘ν μ½μ κ°λ‘μ±λ κ²μ λλ€. main.js νμΌμμ λ€μ λ³κ²½μ μννμμμ€.λ©μΈ.js
mainWindow = new BrowserWindow({width: 1100, height: 700, icon: __dirname + '/icon.ico'}) mainWindow.loadURL(url.format({ pathname:'index.html', protocol: 'file', slashes: true }))
app.on('ready', () => { protocol.interceptFileProtocol('file', (request, callback) => { const url = request.url.substr(7) /* all urls start with 'file://' */ callback({ path: path.normalize(
${__dirname}/${url})}) }, (err) => { if (err) console.error('Failed to register protocol') }) createWindow() /* callback function */ })
οΌ
κ²½λ‘ λ¬Έμ . λΈλΌμ°μ λ D:/css/app.cssμμ νμΌμ κ²μν©λλ€. μ΄κ²μ μ½λ μ΄λκ°μμ μλͺ»λ κ²½λ‘λ₯Ό μΈκΈνκΈ° λλ¬Έμ λλ€. /css/...μ κ°μ κ²½λ‘κ° μ£Όμ΄μ§λ©΄ D:/μμ κ²μλ©λλ€.
μ΄κ²μ λν νΈλ¦μ μννμ΅λλ€. ν΅μ°°λ ₯μ μ£Όμ @itsaakashpatel μ¨μκ² κ°μ¬λ립λλ€.
// ...
const { protocol } = require('electron')
// ...
// run the next block right before <BrowserWindow>.loadFile()
const htmlRootDir = 'dist/'
const indexFile = 'index.html'
protocol.interceptFileProtocol(
'file',
(request, callback) => {
const url = request.url.substr(7) // strip "file://" out of all urls
if (request.url.endsWith(indexFile)) {
callback({ path: url })
} else {
callback({ path: path.normalize(`${__dirname}/${htmlRootDir}/${url}`) })
}
},
error => console.error(error)
)
// ...
htmlRootDir
λ°/λλ indexFile
λ₯Ό μμλλ‘ λ°κΎΈλ©΄ λ©λλ€.
_Linuxμμ ν
μ€νΈλ¨_
@Myrga μ ν루λ₯Ό
@Myrga κΈμ, μ΄λ¬ν κ²λ€μ νλ μ½λ©νλ λμ "homepage": "./"
package.json
μ€μ νμ κ²μ
λλ€.
@Myrga κΈμ, μ΄λ¬ν κ²λ€μ νλ μ½λ©νλ λμ
"homepage": "./"
package.json
μ€μ νμ κ²μ λλ€.
@defusioner μ£ΌμΈμ, μ΄κ²μ λν λ¬Έμκ° μμ΅λκΉ?
@leodutra ν , λλ react-craλ₯Ό μ¬μ©νκ³ μμΌλ©° μ΄λ¬ν ꡬμ±μ μμ±ν μ μμ΅λλ€. https://create-react-app.dev/docs/deployment#building -for-relative-paths
@defusioner ν , λ§μ κ²μ μ€λͺ
ν©λλ€.
μ΄κ²μ μ μ μμ€μ΄ μλ κ² κ°μΌλ©° λ°μ μ±μ© ννμ΄μ§μ λ κ°κΉμ΅λλ€. μ¬κΈ°μ μ΄κ²μ λͺ¨λ μλ λλ λ£¨νΈ λ§ν¬μ κΈ°λ³Έ 루νΈλ₯Ό λ체ν©λλ€.
μ κ²½μ°μλ Vue.js dist λλ raw electronμ μ¬μ©νλ©΄ μλ§λ μλνμ§ μμ κ²μ λλ€.
λλμ΄ ν¨ν€μ§ μ κ·Ό λ°©μμ κ³ λ €ν΄μΌνλ€κ³ μκ°ν©λλ€ ... package.jsonμ electronBasePath
μ κ°μ΄
win.loadFile('index.html')
μ(λ) λ₯ κ°μμ! electron-builder
λ₯Ό μ¬μ©νμ¬ EXE νμΌλ‘ μ»΄νμΌν ν. νμ DevTools failed to load SourceMap: Could not load content for file:///C:/User..../resources/app.asar/bootstrap.min.css.map
λ©λλ€.
κ·Έλ¬λ win.loadURL()
λ μ μλν©λλ€.
λλ μ΄κ²μ΄ λ΄κ° ν΄κ²°ν μ μλ λ²κ·ΈλΌλ κ²μ μμλ΄κΈ° μν΄ 8μκ°μ 보λλ€.
μ§λ νμΌμ μ€μ λ‘ κ°μ Έμ€κΈ° λλ¬Έμ μ΄ λ²κ·Έκ° μ€μνμ§ μλ€λ κ²μ κΉ¨λ¬μμ΅λλ€.
λμκ² μ€μ λ²κ·Έλ alert()
λ‘ μΈν΄ λ°μνμ΅λλ€. https://stackoverflow.com/questions/56805920/cant-edit-input-text-field-after-window-alert
κ°μ₯ μ μ©ν λκΈ
νμνλ©΄μ΄ λ¬Έμ κ° λ°μν κ²½μ°
<base href="/">
λ index.htmlμ λΆκ³Όνμ¬ κ΅μ²΄<base href="./">
.