KITASENJU DESIGN BLOG

memo, html, javascript, unity

webpack.config.jsでエントリーポイントを複数

// pathモジュールの読み込み
const path = require("path");
 
module.exports = {
  // モードを開発モードにする
  //mode: "production",
  
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',//"development",
  
  // 入力ファイル設定
  entry: {
    app:  path.resolve(__dirname, "./src/index.ts"),
    jsonCatcher:  path.resolve(__dirname, "./src/jsonCatcher.ts")
  },
  // 出力ファイル設定
  output: {
    // 出力されるファイル名 app.bundle.js
    filename:'[name].bundle.js',
    // 出力先ディレクトリ
    path: path.resolve(__dirname, "dist/js/"),

    // ライブラリ名 → instance = new window.MyApp.jsonCatcher();
    library: 'MyApp',
    libraryTarget: 'window'

  },
 
  // モジュール設定
  module: {
    rules: [
      {
        // ts-loaderの設定
        test: /\.(js|ts|tsx)?$/,
        use: "ts-loader",
        exclude: /node_modules/
      },
      {
        test: /.(vert|frag|glsl)$/,
        use: ['raw-loader','glslify-loader'],
        include: [path.resolve(__dirname, 'src')],
        exclude: /node_modules/
      }
    ]
  },
  
  resolve: {
    extensions: [".ts", ".js", ".json"]
  },
 
  devtool: "source-map",

  devServer: {
    contentBase: "./dist",
    open: true
  }
};
"FOOTER"