Skip to content

Commit

Permalink
config: 클라이언트 파일rollup 번들링 설정 및 static 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
d0422 committed May 26, 2024
1 parent efa5b37 commit 06413e1
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/miniNext/nodemon.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"watch": ["src"],
"ext": "ts",
"exec": "babel src --extensions .ts,.tsx --out-dir dist && node dist/app.js"
"exec": "babel src --extensions .ts,.tsx --out-dir dist && rollup --config rollup.config.js && node dist/app.js"
}
5 changes: 4 additions & 1 deletion apps/miniNext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/node": "^20.11.30",
"babel-node": "0.0.1-security",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-module-resolver": "^5.0.2",
"nodemon": "^3.1.0",
"rollup": "^4.18.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
Expand Down
41 changes: 41 additions & 0 deletions apps/miniNext/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const babel = require('@rollup/plugin-babel');
const resolve = require('@rollup/plugin-node-resolve');
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
const path = require('path');
console.log('path확인:', path.resolve('jsx-runtime.js'));
module.exports = [
{
input: './public/index.tsx',
output: {
file: './dist/public/index.js',
format: 'es',
},
plugins: [
babel({
babelHelpers: 'bundled',
presets: ['@babel/preset-env', '@babel/preset-typescript'],
plugins: [
[
'@babel/plugin-transform-react-jsx',
{ importSource: '@core', runtime: 'automatic' },
],
[
'module-resolver',
{
alias: {
'@core/jsx-runtime': path.resolve(
__dirname,
'src/core/jsx-runtime'
),
},
},
],
],
extensions,
}),
resolve({
extensions,
}),
],
},
];
2 changes: 1 addition & 1 deletion apps/miniNext/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createHTML } from '@core/createHTML';

const app = express();
const port = 3000;

app.use(express.static('dist/public'));
app.get('/', (req, res) => {
const html = createHTML(<App />);
res.send(html);
Expand Down
Loading

0 comments on commit 06413e1

Please sign in to comment.