diff webpack.config.js @ 33:b82c05e22d9a

change to npm with a build that worked better as a local package to be shared
author drewp@bigasterisk.com
date Tue, 24 Dec 2019 20:30:27 -0800
parents e54941d93356
children
line wrap: on
line diff
--- a/webpack.config.js	Tue Dec 17 23:13:01 2019 -0800
+++ b/webpack.config.js	Tue Dec 24 20:30:27 2019 -0800
@@ -1,63 +1,34 @@
-const glob = require('glob');
-const jest = require('jest');
 const path = require("path");
-const PnpWebpackPlugin = require('pnp-webpack-plugin');
-
-const base = {
-    devtool: 'source-map',
-    module: {
-        rules: [
-            {
-                test: /\.ts$/,
-                loader: require.resolve('ts-loader'),
-                options: PnpWebpackPlugin.tsLoaderOptions({})
-            },
-            {
-                test: /\.css$/i,
-                use: ['file-loader']
-            },
-        ]
-    },
-    resolve: {
-        extensions: [".ts", ".js"],
-        plugins: [PnpWebpackPlugin],
-    }
-};
 
-function outputToBundle(bundleName) {
-    return {
-        filename: bundleName,
-        path: path.resolve(__dirname, 'build'),
-        publicPath: '/build/'
-    };
-}
-
-module.exports = [
-    Object.assign({
-        name: "main",
-        entry: ['./src/streamed-graph.ts'],
-        output: outputToBundle('streamed-graph.bundle.js'),
-        devServer: {
-            port: 8082,
-            publicPath: '/build/',
-            contentBase: __dirname
-        }
-    }, base),
-    Object.assign({
-        name: "test",
-        entry: glob.sync('src/**/*.test.ts').map((p) => './' + p),
-        output: outputToBundle('test.bundle.js'),
-        plugins: [
-            {
-                apply: (compiler) => {
-                    compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
-                        jest.run([
-                            '--detectOpenHandles', // not just to debug; having this quiets a jest error
-                            '--testRegex', 'test.bundle.js', 'build/test.bundle.js']);
-                    });
-                }
-            }
-        ]
-    }, base)
-];
-
+module.exports = {
+  entry: ["./src/index.ts"],
+  output: {
+    library: "streamed_graph",
+    filename: "bundle.js",
+    path: path.resolve(__dirname, "build"),
+    publicPath: "/build/"
+  },
+  module: {
+    rules: [
+      {
+        test: /\.ts$/,
+        loader: require.resolve("ts-loader")
+      },
+      { test: /\.css$/i, use: ["file-loader"] }
+    ]
+  },
+  devtool: "source-map",
+  resolve: {
+    extensions: [".ts", ".js"],
+    modules: ["node_modules"]
+  },
+  watchOptions: {
+    ignored: /node_modules/,
+    poll: 200
+  },
+  devServer: {
+    port: 8082,
+    publicPath: "/build/",
+    contentBase: __dirname
+  }
+};