blob: c07721f5cd9d862aad4d798c912b0515c0d39683 [file] [log] [blame]
herberte6d0d672019-12-14 01:05:47 +01001/**
2 * Webpack 4 configuration file
3 * see https://webpack.js.org/configuration/
4 * see https://webpack.js.org/configuration/dev-server/
5 */
6
7"use strict";
8
9const path = require("path");
10const webpack = require("webpack");
11const TerserPlugin = require('terser-webpack-plugin');
12
13// const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());
14
15module.exports = (env) => {
16 const distPath = path.resolve(__dirname, env === "release" ? "." : "..", "dist");
17 const frameworkPath = path.resolve(__dirname, env === "release" ? "." : "..", "dist");
18 return [{
19 name: "App",
20
21 mode: "none", //disable default behavior
22
23 target: "web",
24
25 context: path.resolve(__dirname, "src"),
26
27 entry: {
28 run: ["./run.ts"]
29 },
30
31 devtool: env === "release" ? false : "source-map",
32
33 resolve: {
34 extensions: [".ts", ".tsx", ".js", ".jsx"]
35 },
36
37 output: {
38 path: distPath,
39 filename: "[name].js",
40 library: "[name]",
41 libraryTarget: "umd2",
42 chunkFilename: "[name].js"
43 },
44 module: {
45 rules: [{
46 test: /\.tsx?$/,
47 exclude: /node_modules/,
48 use: [{
49 loader: "babel-loader"
50 }, {
51 loader: "ts-loader"
52 }]
53 }, {
54 test: /\.jsx?$/,
55 exclude: /node_modules/,
56 use: [{
57 loader: "babel-loader"
58 }]
59 }]
60 },
61 optimization: {
62 noEmitOnErrors: true,
63 namedModules: env !== "release",
64 minimize: env === "release",
65 minimizer: env !== "release" ? [] : [new TerserPlugin({
66 terserOptions: {
67 warnings: false, // false, true, "verbose"
68 compress: {
69 drop_console: true,
70 drop_debugger: true,
71 }
72 }
73 })],
74 },
75 plugins: [
76 new webpack.DllReferencePlugin({
77 context: path.resolve(__dirname, "./src"),
78 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
79 sourceType: "umd2"
80 }),
81
82 ]
83 }
84 ]
85};