1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16const {merge} = require('webpack-merge');
17const configCommon = require('./webpack.config.common');
18const HtmlWebpackPlugin = require('html-webpack-plugin');
19const CopyPlugin = require('copy-webpack-plugin');
20
21const configDev = {
22  mode: 'development',
23  entry: {
24    polyfills: './src/polyfills.ts',
25    styles: ['./src/material-theme.scss', './src/styles.css'],
26    app: './src/main_dev.ts',
27  },
28  devtool: 'source-map',
29
30  externals: {
31    fs: 'fs',
32    path: 'path',
33    crypto: 'crypto',
34  },
35
36  node: {
37    global: false,
38    __filename: false,
39    __dirname: false,
40  },
41
42  plugins: [
43    new HtmlWebpackPlugin({
44      template: 'src/index.html',
45      inject: 'body',
46      inlineSource: '.(css|js)$',
47    }),
48    new CopyPlugin({
49      patterns: [
50        'deps_build/trace_processor/to_be_served/trace_processor.wasm',
51        'deps_build/trace_processor/to_be_served/engine_bundle.js',
52        {from: 'src/adb/winscope_proxy.py', to: 'winscope_proxy.py'},
53        {from: 'src/logo_light_mode.svg', to: 'logo_light_mode.svg'},
54        {from: 'src/logo_dark_mode.svg', to: 'logo_dark_mode.svg'},
55        {
56          from: 'src/viewers/components/rects/cube_partial_shade.svg',
57          to: 'cube_partial_shade.svg',
58        },
59        {
60          from: 'src/viewers/components/rects/cube_full_shade.svg',
61          to: 'cube_full_shade.svg',
62        },
63        {
64          from: 'src/app/components/trackpad_right_click.svg',
65          to: 'trackpad_right_click.svg',
66        },
67        {
68          from: 'src/app/components/trackpad_vertical_scroll.svg',
69          to: 'trackpad_vertical_scroll.svg',
70        },
71        {
72          from: 'src/app/components/trackpad_horizontal_scroll.svg',
73          to: 'trackpad_horizontal_scroll.svg',
74        },
75      ],
76    }),
77  ],
78};
79
80module.exports = merge(configCommon, configDev);
81