소스 검색

fix(karma): After adding 2nd webpack configuration

dev1
Hristo Terezov 4 년 전
부모
커밋
e557b2107c
3개의 변경된 파일95개의 추가작업 그리고 94개의 파일을 삭제
  1. 1
    3
      karma.conf.js
  2. 93
    0
      webpack-shared-config.js
  3. 1
    91
      webpack.config.js

+ 1
- 3
karma.conf.js 파일 보기

@@ -16,7 +16,6 @@ module.exports = function(config) {
16 16
         files: [
17 17
             './doc/example/libs/jquery-2.1.1.js',
18 18
             'node_modules/core-js/index.js',
19
-            './index.js',
20 19
             './modules/**/*.spec.js'
21 20
         ],
22 21
 
@@ -29,7 +28,6 @@ module.exports = function(config) {
29 28
         //  https://npmjs.org/browse/keyword/karma-preprocessor
30 29
         preprocessors: {
31 30
             'node_modules/core-js/**': [ 'webpack' ],
32
-            './index.js': [ 'webpack' ],
33 31
             './**/*.spec.js': [ 'webpack', 'sourcemap' ]
34 32
         },
35 33
 
@@ -62,6 +60,6 @@ module.exports = function(config) {
62 60
         // if true, Karma captures browsers, runs the tests and exits
63 61
         singleRun: true,
64 62
 
65
-        webpack: require('./webpack.config.js')
63
+        webpack: require('./webpack-shared-config')
66 64
     });
67 65
 };

+ 93
- 0
webpack-shared-config.js 파일 보기

@@ -0,0 +1,93 @@
1
+/* global __dirname */
2
+
3
+const process = require('process');
4
+const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5
+
6
+const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
7
+
8
+const minimize
9
+    = process.argv.indexOf('-p') !== -1
10
+        || process.argv.indexOf('--optimize-minimize') !== -1;
11
+
12
+module.exports = {
13
+    // The inline-source-map is used to allow debugging the unit tests with Karma
14
+    devtool: minimize ? 'source-map' : 'inline-source-map',
15
+    mode: minimize ? 'production' : 'development',
16
+    module: {
17
+        rules: [ {
18
+            // Version this build of the lib-jitsi-meet library.
19
+
20
+            loader: 'string-replace-loader',
21
+            options: {
22
+                flags: 'g',
23
+                replace:
24
+                    process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
25
+                search: '{#COMMIT_HASH#}'
26
+            },
27
+            test: `${__dirname}/JitsiMeetJS.js`
28
+        }, {
29
+            // Transpile ES2015 (aka ES6) to ES5.
30
+
31
+            exclude: [
32
+                new RegExp(`${__dirname}/node_modules/(?!@jitsi/js-utils)`)
33
+            ],
34
+            loader: 'babel-loader',
35
+            options: {
36
+                presets: [
37
+                    [
38
+                        '@babel/preset-env',
39
+
40
+                        // Tell babel to avoid compiling imports into CommonJS
41
+                        // so that webpack may do tree shaking.
42
+                        {
43
+                            modules: false,
44
+
45
+                            // Specify our target browsers so no transpiling is
46
+                            // done unnecessarily. For browsers not specified
47
+                            // here, the ES2015+ profile will be used.
48
+                            targets: {
49
+                                chrome: 58,
50
+                                electron: 2,
51
+                                firefox: 54,
52
+                                safari: 11
53
+                            }
54
+                        }
55
+                    ],
56
+                    '@babel/preset-flow'
57
+                ],
58
+                plugins: [
59
+                    '@babel/plugin-transform-flow-strip-types',
60
+                    '@babel/plugin-proposal-class-properties',
61
+                    '@babel/plugin-proposal-export-namespace-from'
62
+                ]
63
+            },
64
+            test: /\.js$/
65
+        } ]
66
+    },
67
+    node: {
68
+        // Allow the use of the real filename of the module being executed. By
69
+        // default Webpack does not leak path-related information and provides a
70
+        // value that is a mock (/index.js).
71
+        __filename: true
72
+    },
73
+    optimization: {
74
+        concatenateModules: minimize
75
+    },
76
+    output: {
77
+        filename: `[name]${minimize ? '.min' : ''}.js`,
78
+        path: process.cwd(),
79
+        sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
80
+    },
81
+    performance: {
82
+        hints: minimize ? 'error' : false,
83
+        maxAssetSize: 750 * 1024,
84
+        maxEntrypointSize: 750 * 1024
85
+    },
86
+    plugins: [
87
+        analyzeBundle
88
+            && new BundleAnalyzerPlugin({
89
+                analyzerMode: 'disabled',
90
+                generateStatsFile: true
91
+            })
92
+    ].filter(Boolean)
93
+};

+ 1
- 91
webpack.config.js 파일 보기

@@ -1,96 +1,6 @@
1
-/* global __dirname */
2
-
3 1
 const process = require('process');
4
-const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5
-
6
-const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
7
-
8
-const minimize
9
-    = process.argv.indexOf('-p') !== -1
10
-        || process.argv.indexOf('--optimize-minimize') !== -1;
11
-
12
-const config = {
13
-    // The inline-source-map is used to allow debugging the unit tests with Karma
14
-    devtool: minimize ? 'source-map' : 'inline-source-map',
15
-    mode: minimize ? 'production' : 'development',
16
-    module: {
17
-        rules: [ {
18
-            // Version this build of the lib-jitsi-meet library.
19
-
20
-            loader: 'string-replace-loader',
21
-            options: {
22
-                flags: 'g',
23
-                replace:
24
-                    process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
25
-                search: '{#COMMIT_HASH#}'
26
-            },
27
-            test: `${__dirname}/JitsiMeetJS.js`
28
-        }, {
29
-            // Transpile ES2015 (aka ES6) to ES5.
30
-
31
-            exclude: [
32
-                new RegExp(`${__dirname}/node_modules/(?!@jitsi/js-utils)`)
33
-            ],
34
-            loader: 'babel-loader',
35
-            options: {
36
-                presets: [
37
-                    [
38
-                        '@babel/preset-env',
39
-
40
-                        // Tell babel to avoid compiling imports into CommonJS
41
-                        // so that webpack may do tree shaking.
42
-                        {
43
-                            modules: false,
44 2
 
45
-                            // Specify our target browsers so no transpiling is
46
-                            // done unnecessarily. For browsers not specified
47
-                            // here, the ES2015+ profile will be used.
48
-                            targets: {
49
-                                chrome: 58,
50
-                                electron: 2,
51
-                                firefox: 54,
52
-                                safari: 11
53
-                            }
54
-                        }
55
-                    ],
56
-                    '@babel/preset-flow'
57
-                ],
58
-                plugins: [
59
-                    '@babel/plugin-transform-flow-strip-types',
60
-                    '@babel/plugin-proposal-class-properties',
61
-                    '@babel/plugin-proposal-export-namespace-from'
62
-                ]
63
-            },
64
-            test: /\.js$/
65
-        } ]
66
-    },
67
-    node: {
68
-        // Allow the use of the real filename of the module being executed. By
69
-        // default Webpack does not leak path-related information and provides a
70
-        // value that is a mock (/index.js).
71
-        __filename: true
72
-    },
73
-    optimization: {
74
-        concatenateModules: minimize
75
-    },
76
-    output: {
77
-        filename: `[name]${minimize ? '.min' : ''}.js`,
78
-        path: process.cwd(),
79
-        sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
80
-    },
81
-    performance: {
82
-        hints: minimize ? 'error' : false,
83
-        maxAssetSize: 750 * 1024,
84
-        maxEntrypointSize: 750 * 1024
85
-    },
86
-    plugins: [
87
-        analyzeBundle
88
-            && new BundleAnalyzerPlugin({
89
-                analyzerMode: 'disabled',
90
-                generateStatsFile: true
91
-            })
92
-    ].filter(Boolean)
93
-};
3
+const config = require('./webpack-shared-config');
94 4
 
95 5
 module.exports = [
96 6
     Object.assign({}, config, {

Loading…
취소
저장