File: webpack.config.js

package info (click to toggle)
node-source-map 0.7.0%2B%2Bdfsg2%2Breally.0.6.1-7~bpo10%2B1
  • links: PTS, VCS
  • area: main
  • in suites: buster-backports
  • size: 476 kB
  • sloc: javascript: 4,881; makefile: 16; sh: 4
file content (98 lines) | stat: -rw-r--r-- 2,235 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var BannerPlugin = require("webpack/lib/BannerPlugin");
var fs = require("fs");
var path = require("path");
var webpack = require("webpack");
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');

var distDir = path.join(__dirname, "dist");

module.exports = [
  // Plain build.
  {
    entry: "./source-map.js",
    output: {
      path: distDir,
      filename: "source-map.js",
      library: "sourceMap",
      libraryTarget: "umd",
      globalObject: 'this',
    },
  },

  // Debug build.
  {
    entry: "./source-map.js",
    output: {
      path: distDir,
      filename: "source-map.debug.js",
      library: "sourceMap",
      libraryTarget: "umd",
      globalObject: 'this',
    },
    devtool: "#inline-source-map"
  },

  // Minified build.
  {
    entry: "./source-map.js",
    output: {
      path: distDir,
      filename: "source-map.min.js",
      library: "sourceMap",
      libraryTarget: "umd",
      globalObject: 'this',
    },
    devtool: "#source-map",
    optimization: {
      minimize: true,
      minimizer: [
        new UglifyJsPlugin({
          cache: true,
          parallel: true,
          uglifyOptions: {
            compress: false,
            ecma: 6,
            mangle: true
          },
          sourceMap: true
        })
      ]
    }
  }
];

/*** Build the tests for inclusion in mozilla-central. ************************/

var testFileRegex = /^test\-.*?\.js/;

function isTestFile(file) {
  return testFileRegex.test(file);
}

var testsDir = path.join(__dirname, "test");
var testFiles = fs.readdirSync(testsDir).filter(isTestFile);

// The xpcshell test harness expects a run_test function. Define this function
// and stringify it as banner at the top of each test file.
function run_test() {
  for (var k in SOURCE_MAP_TEST_MODULE) {
    if (/^test/.test(k)) {
      SOURCE_MAP_TEST_MODULE[k](assert);
    }
  }
}

testFiles.forEach(function (file) {
  module.exports.push({
    entry: path.join(testsDir, file),
    output: {
      path: path.join(distDir, "test"),
      filename: file.replace(/\-/g, "_"),
      library: "SOURCE_MAP_TEST_MODULE"
    },
    plugins: [
      new BannerPlugin(run_test.toString() + "\n\n")
    ],
    devtool: "#inline-source-map"
  });
});