blob: 080da8005983b360f3a550de308b88292bece8ca [file] [log] [blame]
Pablo Gamitobb31f2f2020-06-19 17:50:08 +01001/*
2 * Copyright 2017, 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 */
16
17const fs = require('fs');
Pablo Gamito98fd2f42020-09-30 17:57:23 +020018const path = require('path');
19const glob = require('glob');
20const KotlinWebpackPlugin = require('@jetbrains/kotlin-webpack-plugin');
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010021
22function getWaylandSafePath() {
Pablo Gamito98fd2f42020-09-30 17:57:23 +020023 waylandPath = path.resolve(
24 __dirname, '../../../vendor/google_arc/libs/wayland_service');
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010025 if (fs.existsSync(waylandPath)) {
26 return waylandPath;
27 }
28 return path.resolve(__dirname, 'src/stubs');
29}
30
31module.exports = {
32 entry: {
Pablo Gamito98fd2f42020-09-30 17:57:23 +020033 js: glob.sync('./spec/**/*Spec.js'),
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010034 },
35 output: {
36 path: path.resolve(__dirname, './dist'),
Pablo Gamito98fd2f42020-09-30 17:57:23 +020037 filename: 'bundleSpec.js',
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010038 },
39 target: 'node',
40 node: {
41 __dirname: false,
42 },
43 module: {
44 rules: [
45 {
46 test: /\.js$/,
47 loader: 'babel-loader',
Pablo Gamito98fd2f42020-09-30 17:57:23 +020048 exclude: /node_modules/,
49 },
50 {
51 test: /\.tsx?$/,
52 use: 'ts-loader',
53 include: path.resolve(__dirname, './src'),
54 exclude: /node_modules/,
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010055 },
56 {
57 test: /\.proto$/,
58 loader: 'proto-loader',
59 options: {
60 paths: [
61 path.resolve(__dirname, '../../..'),
Pablo Gamito98fd2f42020-09-30 17:57:23 +020062 path.resolve(__dirname, '../../../external/protobuf/src'),
63 ],
64 },
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010065 },
66 {
Nataniel Borges2aa5a1d2021-07-20 21:19:53 +020067 test: /\.(pb|winscope)/,
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010068 loader: 'file-loader',
69 options: {
70 paths: [
Pablo Gamito98fd2f42020-09-30 17:57:23 +020071 path.resolve(__dirname, './spec'),
72 ],
73 },
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010074 },
Pablo Gamito98fd2f42020-09-30 17:57:23 +020075 ],
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010076 },
77 resolve: {
Pablo Gamito98fd2f42020-09-30 17:57:23 +020078 extensions: ['.tsx', '.ts', '.js', '.vue'],
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010079 alias: {
Pablo Gamito98fd2f42020-09-30 17:57:23 +020080 '@': path.resolve(__dirname, 'src'),
81 'WaylandSafePath': getWaylandSafePath(),
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010082 },
83 modules: [
84 'node_modules',
Pablo Gamito98fd2f42020-09-30 17:57:23 +020085 'kotlin_build',
86 path.resolve(__dirname, '../../..'),
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010087 ],
88 },
89 resolveLoader: {
90 modules: [
91 'node_modules',
Pablo Gamito98fd2f42020-09-30 17:57:23 +020092 path.resolve(__dirname, 'loaders'),
93 ],
Pablo Gamitobb31f2f2020-06-19 17:50:08 +010094 },
Pablo Gamito98fd2f42020-09-30 17:57:23 +020095 plugins: [
96 new KotlinWebpackPlugin({
97 src: [
98 path.join(__dirname, '../../../platform_testing/libraries/flicker/' +
Nataniel Borges95347472020-10-23 14:22:19 +020099 'src/com/android/server/wm/traces/common/'),
Pablo Gamito98fd2f42020-09-30 17:57:23 +0200100 ],
101 output: 'kotlin_build',
102 moduleName: 'flicker',
103 librariesAutoLookup: true,
104 sourceMaps: true,
105 sourceMapEmbedSources: 'always',
106 verbose: true,
107 optimize: true,
108 }),
109 ],
Pablo Gamitobb31f2f2020-06-19 17:50:08 +0100110 devServer: {
111 historyApiFallback: true,
Pablo Gamito98fd2f42020-09-30 17:57:23 +0200112 noInfo: true,
Pablo Gamitobb31f2f2020-06-19 17:50:08 +0100113 },
114 performance: {
Pablo Gamito98fd2f42020-09-30 17:57:23 +0200115 hints: false,
116 },
117};