瀏覽代碼

Allow ignore bootstrap modules at build (#1852)

* This allow you to ignore some bootstrap modules you have already included/imported
to your project. Fix error: In a webpage you are already using bootstrap and have
a dropdown, but you have to click twice to make it work, because conversejs added
another handler.

* Add:
   - Allow ignoring bootstrap modules using environment variable: BOOTSTRAP_IGNORE_MODULES="Modal,Dropdown".
     Example: export BOOTSTRAP_IGNORE_MODULES="Modal,Dropdown" ; make dist
GriZmio 5 年之前
父節點
當前提交
897d3af277
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 2 0
      CHANGES.md
  2. 7 1
      webpack.common.js

+ 2 - 0
CHANGES.md

@@ -14,6 +14,8 @@
     and [muc_roomid_policy_hint](https://conversejs.org/docs/html/configuration.html#muc-roomid-policy-hint)
     and [muc_roomid_policy_hint](https://conversejs.org/docs/html/configuration.html#muc-roomid-policy-hint)
 - #1826: A user can now add himself as a contact
 - #1826: A user can now add himself as a contact
 - #1839: Headline messages are shown in controlbox
 - #1839: Headline messages are shown in controlbox
+- Allow ignore bootstrap modules at build using environment variable: BOOTSTRAP_IGNORE_MODULES="Modal,Dropdown".
+  example: export BOOTSTRAP_IGNORE_MODULES="Modal,Dropdown" && make dist
 
 
 ## 6.0.0 (2020-01-09)
 ## 6.0.0 (2020-01-09)
 
 

+ 7 - 1
webpack.common.js

@@ -1,6 +1,12 @@
 /* global __dirname, module */
 /* global __dirname, module */
 const path = require('path');
 const path = require('path');
 
 
+bootstrap_ignore_modules = ['carousel', 'scrollspy'];
+
+BOOTSTRAP_IGNORE_MODULES = (process.env.BOOTSTRAP_IGNORE_MODULES || '').replace(/ /g, '').trim();
+if(BOOTSTRAP_IGNORE_MODULES.length > 0)
+    bootstrap_ignore_modules = bootstrap_ignore_modules.concat(BOOTSTRAP_IGNORE_MODULES.split(','));
+
 module.exports = {
 module.exports = {
     output: {
     output: {
         path: path.resolve(__dirname, 'dist'), // Output path for generated bundles
         path: path.resolve(__dirname, 'dist'), // Output path for generated bundles
@@ -103,7 +109,7 @@ module.exports = {
                 loader: 'bootstrap.native-loader',
                 loader: 'bootstrap.native-loader',
                 options: {
                 options: {
                     bs_version: 4,
                     bs_version: 4,
-                    ignore: ['carousel', 'scrollspy']
+                    ignore: bootstrap_ignore_modules
                 }
                 }
             }
             }
         }],
         }],