webpack과 electron을 동시에 돌리는 법 · The Chat Archive
Explore / Science webpack과 electron을 동시에 돌리는 법 Save Share Download ▾ Reportwebpack과 electron을 동시에 돌리는 법
Assistant2025-02-13 09:34 UTC Copy response
Webpack과 Electron을 동시에 돌리는 방법에는 여러 가지가 있지만, 기본적으로 두 가지 프로세스를 설정해야 합니다. 하나는 Webpack으로 프론트엔드 자산을 빌드하는 것이고, 다른 하나는 Electron으로 데스크탑 응용 프로그램을 실행하는 것입니다. 아래에 기본적인 설정 방법을 설명하겠습니다.
Copy first prompt Copy first response
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Provider OpenAI
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language ko
Conversation date Feb 13, 2025
Added to archive Nov 16, 2026
ID 01m7h42fqtqwgp88yc23a8pvm9Source & license Imported from WildChat-4.8M (AI2) (source ). Imported records earn no Research Points.
Upstream record: 854a375e34609ec4a7f3e8cf8e7e937b
Zhao et al., WildChat: 1M ChatGPT Interaction Logs in the Wild (ICLR 2024). Contains information from WildChat-4.8M, made available under the ODC Attribution License.
License: ODC-BY-1.0
1단계: 초기 프로젝트 설정 먼저 프로젝트 폴더를 만들고 필요한 패키지를 설치합니다.
mkdir my-electron-app
cd my-electron-app
npm init -y
npm install --save-dev webpack webpack-cli webpack-dev-server
npm install --save-dev electron
2단계: Webpack 설정 webpack.config.js 파일을 생성하고 다음과 같이 설정합니다.
const path = require('path');
module.exports = {
mode: 'development',
entry: './src/index.js', // 진입 파일
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
devtool: 'source-map',
};
3단계: Electron 메인 프로세스 설정 main.js 파일을 생성하여 Electron의 메인 프로세스를 설정합니다.
const { app, BrowserWindow } = require('electron');
const path = require('path');
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
enableRemoteModule: false,
},
});
win.loadURL('http://localhost:8080'); // Webpack Dev Server의 주소
}
app.whenReady().then(createWindow);
4단계: package.json 수정 package.json 파일에 스크립트를 추가하여 Webpack과 Electron을 동시에 실행할 수 있도록 설정합니다.
"scripts": {
"start": "webpack-dev-server --open",
"electron": "electron .",
"dev": "npm-run-all --parallel start electron"
},
"devDependencies": {
"npm-run-all": "^4.1.5"
}
5단계: 프로젝트 폴더 구조 my-electron-app
│
├── dist/ # Webpack 빌드 결과
├── node_modules/
├── src/
│ └── index.js # 진입 파일
├── main.js # Electron 메인 프로세스
├── package.json
└── webpack.config.js
6단계: 개발 서버 및 Electron 실행 이제 dev 스크립트를 실행하여 Webpack Dev Server와 Electron을 동시에 실행할 수 있습니다.
추가 팁
Webpack의 devServer를 사용하여 핫 리로딩을 설정하면 코드 수정 시 변경사항이 즉시 반영됩니다.
실제 빌드를 진행할 경우, Webpack으로 빌드한 파일을 Electron이 로드할 수 있도록 파일 경로를 수정해야 합니다.
이 기본 설정을 바탕으로 필요한 패키지나 기능을 추가하여 프로젝트를 발전시킬 수 있습니다.
Not yet included in a published release.