#author("2019-04-23T14:24:47+09:00","default:ryuichi","ryuichi")
** NPM package.json初期化 [#xa85a3cd]

 npm init -y

** Webpack インストール [#y4ba9355]

 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')
    }
  };
 -----

- https://github.com/babel/babel-loader

** TypeScirpt インストール [#za569842]

 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']
   },
 -----

- https://github.com/TypeStrong/ts-loader#configuration

** Express.js インストール [#m81f1a3a]

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

** Git リポジトリ初期化 [#ma4de9ef]

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

** Express.js アプリケーション作成 [#x4d9b3df]

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

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