Skip to content

Commit

Permalink
chore: add ts and mts config example
Browse files Browse the repository at this point in the history
  • Loading branch information
hardfist committed Jan 26, 2024
1 parent 4f397ac commit c54eea0
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 6 deletions.
12 changes: 12 additions & 0 deletions rspack/basic-mts-config/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
20 changes: 20 additions & 0 deletions rspack/basic-mts-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "example-basic-tsconfig",
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS=\"--loader ts-node/esm\" rspack serve",
"build": "NODE_OPTIONS=\"--loader ts-node/esm\" rspack build"
},
"devDependencies": {
"@rspack/cli": "latest",
"@rspack/core": "latest",
"ts-node": "10.9.2"
},
"sideEffects": false,
"keywords": [],
"author": "",
"license": "MIT"
}
16 changes: 16 additions & 0 deletions rspack/basic-mts-config/rspack.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import rspack from "@rspack/core";
import path from 'path';
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

/** @type {import('@rspack/cli').Configuration} */
const config = {
context: __dirname,
entry: "./src/index.js",
plugins: [
new rspack.HtmlRspackPlugin({
template: "./index.html"
})
]
};
export default config;
1 change: 1 addition & 0 deletions rspack/basic-mts-config/src/answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const answer = 42;
7 changes: 7 additions & 0 deletions rspack/basic-mts-config/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { answer } from "./answer";
function render() {
document.getElementById(
"root"
).innerHTML = `the answer to the universe is ${answer}`;
}
render();
15 changes: 15 additions & 0 deletions rspack/basic-mts-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"target": "ESNext",
"module": "NodeNext",
"noEmit":true,
"esModuleInterop": true,
"resolveJsonModule":true,
"moduleResolution": "nodenext",
"allowImportingTsExtensions": true,
"allowSyntheticDefaultImports": true,
},
"include": ["**/*.ts", "**/*.js"]
}
13 changes: 7 additions & 6 deletions rspack/basic/rspack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const rspack = require("@rspack/core");
/** @type {import('@rspack/cli').Configuration} */
const config = {
entry: "./src/index.js",
plugins: [
new rspack.HtmlRspackPlugin({
template: "./index.html"
})
]
context: __dirname,
entry: "./src/index.js",
plugins: [
new rspack.HtmlRspackPlugin({
template: "./index.html",
}),
],
};
module.exports = config;

0 comments on commit c54eea0

Please sign in to comment.