浏览代码

Merge pull request #903 from jitsi/webpack

Switch from Browserify to Webpack
j8
hristoterezov 8 年前
父节点
当前提交
77e65f727f
共有 5 个文件被更改,包括 173 次插入114 次删除
  1. 8
    0
      .babelrc
  2. 3
    2
      .jshintignore
  3. 24
    37
      Makefile
  4. 19
    75
      package.json
  5. 119
    0
      webpack.config.babel.js

+ 8
- 0
.babelrc 查看文件

@@ -0,0 +1,8 @@
1
+{
2
+    "plugins": [
3
+        "transform-object-rest-spread"
4
+    ],
5
+    "presets": [
6
+        "es2015"
7
+    ]
8
+}

+ 3
- 2
.jshintignore 查看文件

@@ -1,4 +1,5 @@
1
-node_modules
2
-libs
3 1
 debian
2
+libs
3
+node_modules
4 4
 analytics.js
5
+webpack.config.babel.js

+ 24
- 37
Makefile 查看文件

@@ -1,20 +1,17 @@
1
-NPM = npm
2
-BROWSERIFY = ./node_modules/.bin/browserify
3
-NODE_SASS = ./node_modules/.bin/node-sass
4
-UGLIFYJS = ./node_modules/.bin/uglifyjs
5
-EXORCIST = ./node_modules/.bin/exorcist
1
+BUILD_DIR = build
6 2
 CLEANCSS = ./node_modules/.bin/cleancss
7
-STYLES_MAIN = css/main.scss
8
-STYLES_UNSUPPORTED_BROWSER = css/unsupported_browser.scss
9
-STYLES_BUNDLE = css/all.bundle.css
10
-STYLES_DESTINATION = css/all.css
11 3
 DEPLOY_DIR = libs
12
-BROWSERIFY_FLAGS = -d
13
-OUTPUT_DIR = .
14 4
 LIBJITSIMEET_DIR = node_modules/lib-jitsi-meet/
15
-IFRAME_API_DIR = ./modules/API/external
5
+NODE_SASS = ./node_modules/.bin/node-sass
6
+NPM = npm
7
+OUTPUT_DIR = .
8
+STYLES_BUNDLE = css/all.bundle.css
9
+STYLES_DESTINATION = css/all.css
10
+STYLES_MAIN = css/main.scss
11
+STYLES_UNSUPPORTED_BROWSER = css/unsupported_browser.scss
12
+WEBPACK = ./node_modules/.bin/webpack
16 13
 
17
-all: update-deps compile compile-iframe-api uglify uglify-iframe-api deploy clean
14
+all: update-deps compile deploy clean
18 15
 
19 16
 # FIXME: there is a problem with node-sass not correctly installed (compiled)
20 17
 # a quick fix to make sure it is installed on every update
@@ -23,13 +20,10 @@ update-deps:
23 20
 	$(NPM) update && $(NPM) install node-sass
24 21
 
25 22
 compile:
26
-	$(BROWSERIFY) $(BROWSERIFY_FLAGS) -e app.js -s APP | $(EXORCIST) $(OUTPUT_DIR)/app.bundle.js.map > $(OUTPUT_DIR)/app.bundle.js
27
-
28
-compile-iframe-api:
29
-	$(BROWSERIFY) $(BROWSERIFY_FLAGS) -e $(IFRAME_API_DIR)/external_api.js -s JitsiMeetExternalAPI | $(EXORCIST) $(OUTPUT_DIR)/external_api.js.map > $(OUTPUT_DIR)/external_api.js
23
+	$(WEBPACK) -p
30 24
 
31 25
 clean:
32
-	rm -f $(OUTPUT_DIR)/app.bundle.* $(OUTPUT_DIR)/external_api.*
26
+	rm -fr $(BUILD_DIR)
33 27
 
34 28
 deploy: deploy-init deploy-appbundle deploy-lib-jitsi-meet deploy-css deploy-local
35 29
 
@@ -37,20 +31,20 @@ deploy-init:
37 31
 	mkdir -p $(DEPLOY_DIR)
38 32
 
39 33
 deploy-appbundle:
40
-	cp $(OUTPUT_DIR)/app.bundle.min.js $(OUTPUT_DIR)/app.bundle.min.map \
41
-	$(OUTPUT_DIR)/app.bundle.js $(OUTPUT_DIR)/app.bundle.js.map \
42
-	$(OUTPUT_DIR)/external_api.js.map $(OUTPUT_DIR)/external_api.js \
43
-	$(OUTPUT_DIR)/external_api.min.map $(OUTPUT_DIR)/external_api.min.js \
44
-	$(OUTPUT_DIR)/analytics.js \
45
-	$(DEPLOY_DIR)
34
+	cp \
35
+		$(BUILD_DIR)/app.bundle.min.js \
36
+		$(BUILD_DIR)/app.bundle.min.map \
37
+		$(BUILD_DIR)/external_api.min.js \
38
+		$(BUILD_DIR)/external_api.min.map \
39
+		$(OUTPUT_DIR)/analytics.js \
40
+		$(DEPLOY_DIR)
46 41
 
47 42
 deploy-lib-jitsi-meet:
48
-	cp $(LIBJITSIMEET_DIR)/lib-jitsi-meet.min.js \
49
-	$(LIBJITSIMEET_DIR)/lib-jitsi-meet.min.map \
50
-	$(LIBJITSIMEET_DIR)/lib-jitsi-meet.js \
51
-	$(LIBJITSIMEET_DIR)/lib-jitsi-meet.js.map \
52
-	$(LIBJITSIMEET_DIR)/connection_optimization/external_connect.js \
53
-	$(DEPLOY_DIR)
43
+	cp \
44
+		$(LIBJITSIMEET_DIR)/lib-jitsi-meet.min.js \
45
+		$(LIBJITSIMEET_DIR)/lib-jitsi-meet.min.map \
46
+		$(LIBJITSIMEET_DIR)/connection_optimization/external_connect.js \
47
+		$(DEPLOY_DIR)
54 48
 
55 49
 deploy-css:
56 50
 	$(NODE_SASS) css/unsupported_browser.scss css/unsupported_browser.css ; \
@@ -61,13 +55,6 @@ deploy-css:
61 55
 deploy-local:
62 56
 	([ ! -x deploy-local.sh ] || ./deploy-local.sh)
63 57
 
64
-uglify:
65
-	$(UGLIFYJS) -p relative $(OUTPUT_DIR)/app.bundle.js -o $(OUTPUT_DIR)/app.bundle.min.js --source-map $(OUTPUT_DIR)/app.bundle.min.map --in-source-map $(OUTPUT_DIR)/app.bundle.js.map
66
-
67
-uglify-iframe-api:
68
-	$(UGLIFYJS) -p relative $(OUTPUT_DIR)/external_api.js -o $(OUTPUT_DIR)/external_api.min.js --source-map $(OUTPUT_DIR)/external_api.min.map --in-source-map $(OUTPUT_DIR)/external_api.js.map
69
-
70
-
71 58
 source-package:
72 59
 	mkdir -p source_package/jitsi-meet/css && \
73 60
 	cp -r *.js *.html connection_optimization favicon.ico fonts images libs sounds LICENSE lang source_package/jitsi-meet && \

+ 19
- 75
package.json 查看文件

@@ -22,13 +22,13 @@
22 22
     "bootstrap": "3.1.1",
23 23
     "events": "*",
24 24
     "i18next-client": "1.7.7",
25
-    "jQuery-Impromptu": "git+https://github.com/trentrichardson/jQuery-Impromptu.git#v6.0.0",
25
+    "jQuery-Impromptu": "trentrichardson/jQuery-Impromptu#v6.0.0",
26 26
     "jquery": "~2.1.1",
27 27
     "jquery-contextmenu": "*",
28 28
     "jquery-ui": "1.10.5",
29 29
     "jssha": "1.5.0",
30 30
     "jws": "*",
31
-    "lib-jitsi-meet": "git+https://github.com/jitsi/lib-jitsi-meet.git",
31
+    "lib-jitsi-meet": "jitsi/lib-jitsi-meet",
32 32
     "postis": "^2.2.0",
33 33
     "retry": "0.6.1",
34 34
     "strophe": "^1.2.2",
@@ -36,95 +36,39 @@
36 36
     "toastr": "^2.0.3"
37 37
   },
38 38
   "devDependencies": {
39
+    "babel-core": "*",
40
+    "babel-loader": "*",
41
+    "babel-plugin-transform-object-rest-spread": "*",
39 42
     "babel-polyfill": "*",
40 43
     "babel-preset-es2015": "*",
41
-    "babelify": "*",
42
-    "browserify": "11.1.x",
43
-    "browserify-css": "^0.9.2",
44
-    "browserify-shim": "^3.8.10",
44
+    "babel-register": "*",
45 45
     "clean-css": "*",
46
-    "exorcist": "*",
46
+    "css-loader": "*",
47
+    "expose-loader": "*",
48
+    "file-loader": "*",
49
+    "imports-loader": "*",
47 50
     "jshint": "2.8.0",
48 51
     "node-sass": "^3.8.0",
49 52
     "precommit-hook": "3.0.0",
50
-    "uglify-js": "2.4.24"
53
+    "string-replace-loader": "*",
54
+    "style-loader": "*",
55
+    "webpack": "*"
51 56
   },
52 57
   "license": "Apache-2.0",
53 58
   "scripts": {
54
-    "lint": "./node_modules/.bin/jshint .",
59
+    "lint": "jshint .",
55 60
     "validate": "npm ls"
56 61
   },
57 62
   "pre-commit": [
58 63
     "lint"
59 64
   ],
60
-  "browserify": {
61
-    "transform": [
62
-      "browserify-shim",
63
-      "browserify-css",
64
-      [
65
-        "babelify",
66
-        {
67
-          "ignore": "node_modules"
68
-        }
69
-      ]
70
-    ]
71
-  },
72
-  "babel": {
73
-    "presets": [
74
-      "es2015"
75
-    ]
76
-  },
77 65
   "browser": {
78
-    "jquery": "./node_modules/jquery/dist/jquery.js",
79
-    "jquery-ui": "./node_modules/jquery-ui/jquery-ui.js",
80
-    "strophe": "./node_modules/strophe/strophe.js",
66
+    "aui-css": "./node_modules/@atlassian/aui/dist/aui/css/aui.min.css",
67
+    "aui-experimental-css": "./node_modules/@atlassian/aui/dist/aui/css/aui-experimental.min.css",
68
+    "autosize": "./node_modules/autosize/build/jquery.autosize.js",
69
+    "popover": "./node_modules/bootstrap/js/popover.js",
81 70
     "strophe-disco": "./node_modules/strophejs-plugins/disco/strophe.disco.js",
82 71
     "strophe-caps": "./node_modules/strophejs-plugins/caps/strophe.caps.jsonly.js",
83
-    "toastr": "./node_modules/toastr/toastr.js",
84
-    "tooltip": "./node_modules/bootstrap/js/tooltip.js",
85
-    "popover": "./node_modules/bootstrap/js/popover.js",
86
-    "jQuery-Impromptu": "./node_modules/jQuery-Impromptu/dist/jquery-impromptu.js",
87
-    "autosize": "./node_modules/autosize/build/jquery.autosize.js",
88
-    "aui": "./node_modules/@atlassian/aui/dist/aui/js/aui.js",
89
-    "aui-experimental": "./node_modules/@atlassian/aui/dist/aui/js/aui-experimental.js",
90
-    "aui-css": "./node_modules/@atlassian/aui/dist/aui/css/aui.min.css",
91
-    "aui-experimental-css": "./node_modules/@atlassian/aui/dist/aui/css/aui-experimental.min.css"
92
-  },
93
-  "browserify-shim": {
94
-    "jquery": [
95
-      "$"
96
-    ],
97
-    "strophe": {
98
-      "exports": "Strophe",
99
-      "depends": [
100
-        "jquery:$"
101
-      ]
102
-    },
103
-    "strophe-disco": {
104
-      "depends": [
105
-        "strophe:Strophe"
106
-      ]
107
-    },
108
-    "tooltip": {
109
-      "depends": "jquery:jQuery"
110
-    },
111
-    "popover": {
112
-      "depends": "jquery:jQuery"
113
-    },
114
-    "jQuery-Impromptu": {
115
-      "depends": "jquery:jQuery"
116
-    },
117
-    "aui-experimental": {
118
-      "depends": "aui:AJS"
119
-    },
120
-    "jquery-contextmenu": {
121
-      "depends": "jquery:jQuery"
122
-    },
123
-    "autosize": {
124
-      "depends": "jquery:jQuery"
125
-    },
126
-    "browserify-css": {
127
-        "autoInject": true
128
-    }
72
+    "tooltip": "./node_modules/bootstrap/js/tooltip.js"
129 73
   }
130 74
 }

+ 119
- 0
webpack.config.babel.js 查看文件

@@ -0,0 +1,119 @@
1
+import process from 'process';
2
+import webpack from 'webpack';
3
+
4
+const aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/';
5
+const minimize
6
+    = process.argv.indexOf('-p') != -1
7
+        || process.argv.indexOf('--optimize-minimize') != -1;
8
+const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
9
+
10
+// The base Webpack configuration to bundle the JavaScript artifacts of
11
+// jitsi-meet such as app.bundle.js and external_api.js.
12
+const config = {
13
+    devtool: 'source-map',
14
+    module: {
15
+        loaders: [{
16
+            // Transpile ES2015 (aka ES6) to ES5.
17
+
18
+            exclude: [
19
+                __dirname + '/modules/RTC/adapter.screenshare.js',
20
+                __dirname + '/node_modules/'
21
+            ],
22
+            loader: 'babel',
23
+            test: /\.js$/
24
+        },{
25
+            // Expose jquery as the globals $ and jQuery because it is expected
26
+            // to be available in such a form by multiple jitsi-meet
27
+            // dependencies including AUI, lib-jitsi-meet.
28
+
29
+            loader: 'expose?$!expose?jQuery',
30
+            test: /\/node_modules\/jquery\/.*\.js$/
31
+        },{
32
+            // Disable AMD for the Strophe.js library or its imports will fail
33
+            // at runtime.
34
+
35
+            loader: 'imports?define=>false&this=>window',
36
+            test: strophe
37
+        },{
38
+            // Allow CSS to be imported into JavaScript.
39
+
40
+            loaders: [
41
+                'style',
42
+                'css'
43
+            ],
44
+            test: /\.css$/
45
+        },{
46
+            // Emit the static assets of AUI such as images that are referenced
47
+            // by CSS into the output path.
48
+
49
+            include: aui_css,
50
+            loader: 'file',
51
+            query: {
52
+                context: aui_css,
53
+                name: '[path][name].[ext]'
54
+            },
55
+            test: /\.(gif|png|svg)$/
56
+        }],
57
+        noParse: [
58
+            // Do not parse the files of the Strophe.js library or at least
59
+            // parts of the properties of the Strophe global variable will be
60
+            // missing and strophejs-plugins will fail at runtime.
61
+            strophe
62
+        ]
63
+    },
64
+    node: {
65
+        // Allow the use of the real filename of the module being executed. By
66
+        // default Webpack does not leak path-related information and provides a
67
+        // value that is a mock (/index.js).
68
+        __filename: true
69
+    },
70
+    output: {
71
+        filename: '[name]' + (minimize ? '.min' : '') + '.js',
72
+        libraryTarget: 'umd',
73
+        path: __dirname + '/build',
74
+        sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map'
75
+    },
76
+    resolve: {
77
+        alias: {
78
+            aui:
79
+                '@atlassian/aui/dist/aui/js/aui'
80
+                    + (minimize ? '.min' : '')
81
+                    + '.js',
82
+            'aui-experimental':
83
+                '@atlassian/aui/dist/aui/js/aui-experimental'
84
+                    + (minimize ? '.min' : '')
85
+                    + '.js',
86
+            jquery: 'jquery/dist/jquery' + (minimize ? '.min' : '') + '.js',
87
+            'jQuery-Impromptu':
88
+                'jQuery-Impromptu/dist/jquery-impromptu'
89
+                    + (minimize ? '.min' : '')
90
+                    + '.js',
91
+        },
92
+        packageAlias: 'browser'
93
+    }
94
+};
95
+
96
+export default [{
97
+    // The Webpack configuration to bundle app.bundle.js (aka APP).
98
+
99
+    ...config,
100
+    entry: {
101
+       'app.bundle': './app.js'
102
+    },
103
+    output: {
104
+        ...config.output,
105
+        library: 'APP'
106
+    }
107
+}, {
108
+    // The Webpack configuration to bundle external_api.js (aka
109
+    // JitsiMeetExternalAPI).
110
+
111
+    ...config,
112
+    entry: {
113
+       'external_api': './modules/API/external/external_api.js'
114
+    },
115
+    output: {
116
+        ...config.output,
117
+        library: 'JitsiMeetExternalAPI'
118
+    }
119
+}];

正在加载...
取消
保存