NPM package.json初期化

 npm init -y

Webpack インストール

 npm install -D webpack webpack-cli '@webpack-cli/init'
 npm install -D webpack-node-externals
 npm install -D rimraf mkdirp
 vim webpack.config.js
 -----
  const path = require('path');
  
  module.exports = {
    target: 'node',
    mode: 'development',
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env']
            }
          }
        }
    },
    resolve: {
      extensions: ['.js']
    },
    output: {
      filename: 'bundle.js',
      path: path.resolve(__dirname, 'dist')
    }
  };
 -----

TypeScirpt インストール

 npm add -D typescript ts-node @types/node core-js ts-loader
 npx tsc --init
 
 vim webpack.config.js
 -----
   module: {
     rules: [
 +     {
 +       test: /\.tsx?$/,
 +       use: 'ts-loader',
 +       exclude: /node_modules/
 +     },
 
   resolve: {
 +   extensions: ['.ts', '.js']
   },
 -----

Express.js インストール

 npm install express
 npm install -D '@types/express'

Git リポジトリ初期化

 vim .gitignore
 -----
 node_modules/
 package-lock.json
 -----
 
 git init
 git add .
 git commit -m 'Initial commit'

Express.js アプリケーション作成

vim package.json


  "scripts": {
  1. "build": "rimraf ./dist && mkdirp ./dist && npx webpack",
  2. "start": "node ./dist/bundle.js",
        "test": "echo \"Error: no test specified\" && exit 1"
      },


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS