Browse Source

webpack builds oldstyle UMD js, too

boyska 2 years ago
parent
commit
06fd8807b3
2 changed files with 24 additions and 12 deletions
  1. 1 1
      index.html
  2. 23 11
      webpack.config.js

+ 1 - 1
index.html

@@ -5,7 +5,7 @@
     <body>
         Ciao
         <script src="libs/ical.min.js"></script>
-        <script src="radiomanifest.js"></script>
+        <script src="dist/radiomanifest-oldstyle.bundle.js"></script>
         <script src="ui.js"></script>
     </body>
 </html>

+ 23 - 11
webpack.config.js

@@ -1,15 +1,27 @@
 const path = require('path')
 
-module.exports = ['web', 'node'].map(
-  target => ({
-    name: target,
-    mode: 'production',
-    entry: './radiomanifest.js',
-    target: [target],
-    output: {
-      path: path.resolve(__dirname, 'dist'),
-      filename: 'radiomanifest-' + target + '.bundle.js',
-      clean: false
+const variants = [
+  { name: 'web', libtype: 'amd', target: 'web' },
+  { name: 'node', libtype: 'amd', target: 'node' },
+  { name: 'oldstyle', libtype: 'umd', target: 'web' }
+]
+module.exports = variants.map(
+  variant => {
+    const obj = {
+      name: variant.name,
+      mode: 'production',
+      entry: './radiomanifest.js',
+      target: [variant.target],
+      output: {
+        path: path.resolve(__dirname, 'dist'),
+        filename: 'radiomanifest-' + variant.name + '.bundle.js',
+        clean: false,
+        library: {
+          name: 'radiomanifest',
+          type: variant.libtype
+        }
+      }
     }
-  })
+    return obj
+  }
 )