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 path = require('path'); 17const TerserPlugin = require('terser-webpack-plugin'); 18 19module.exports = { 20 resolve: { 21 extensions: ['.ts', '.js', '.css'], 22 modules: ['node_modules', 'src', 'kotlin_build', path.resolve(__dirname, '../../..')], 23 }, 24 25 resolveLoader: { 26 modules: ['node_modules', path.resolve(__dirname, 'loaders')], 27 }, 28 29 module: { 30 rules: [ 31 { 32 test: /\.ts$/, 33 use: ['ts-loader', 'angular2-template-loader'], 34 }, 35 { 36 test: /\.html$/, 37 use: ['html-loader'], 38 }, 39 { 40 test: /\.css$/, 41 use: ['style-loader', 'css-loader'], 42 }, 43 { 44 test: /\.s[ac]ss$/i, 45 use: ['style-loader', 'css-loader', 'sass-loader'], 46 }, 47 { 48 test: /\.proto$/, 49 loader: 'proto-loader', 50 options: { 51 paths: [ 52 path.resolve(__dirname, '../../..'), 53 path.resolve(__dirname, '../../../external/protobuf/src'), 54 ], 55 }, 56 }, 57 ], 58 }, 59 60 optimization: { 61 minimizer: [ 62 new TerserPlugin({ 63 terserOptions: { 64 keep_fnames: true, 65 }, 66 }), 67 ], 68 }, 69}; 70