Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Hamberfim/et4_webapp

Repository files navigation

A Stand-Alone Typescript Web App

Alt

Toolchain Creation Steps

  1. npm init -y | if using this template => 'npm install' and skip ahead to step 8
  2. npm i -D typescript
  3. npx tsc --init to create 'tsconfig.json' in root dir with minimum config settings below
"compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "outDir": "./dist",
    "rootDir": "./src",
}
  1. create a 'src' folder in the root dir and add a index.ts to it with a console.log("some message)

  2. npm i -D typescript webpack webpack-cli ts-loader

  3. npm i -D webpack-dev-server

  4. new file in root dir 'webpack.config.js' with minimum config settings below

module.exports = {
  mode: "development",
  devtool: "inline-source-map",
  entry: "/src/index.ts",
  output: { filename: "bundle.js" },
  resolve: { extensions: [".ts", ".js"] },
  module: {
    rules: [{ test: /\.ts/, use: "ts-loader", exclude: /node_modules/ }],
  },
  devServer: {
    static: "./assets",
    port: 4500,
  },
};
  1. run 'npx webpack'
  2. run 'node dist/bundle.js'
  3. new folder in root dir 'assets'
  4. new file in assets dir 'index.html with minimum code below
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="bundle.js"></script>
    <title>Web App</title>
  </head>
  <body>
    <div id="app">PLACEHOLDER</div>
  </body>
</html>
  1. run 'npx webpack serve'
  2. stop webpack serve and run 'npm i bootstrap' & then
  3. npm i -D css-loader style-loader
  4. add to the webpack.config.js resolve & rules array
...
resolve: { extensions: [".ts", ".tsx", ".js", ".css"] },
...
rules: [...
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published