1/* 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'); 18const path = require('path'); 19const glob = require('glob'); 20const KotlinWebpackPlugin = require('@jetbrains/kotlin-webpack-plugin'); 21 22function getWaylandSafePath() { 23 waylandPath = path.resolve( 24 __dirname, '../../../vendor/google_arc/libs/wayland_service'); 25 if (fs.existsSync(waylandPath)) { 26 return waylandPath; 27 } 28 return path.resolve(__dirname, 'src/stubs'); 29} 30 31module.exports = { 32 entry: { 33 js: glob.sync('./spec/**/*Spec.js'), 34 }, 35 output: { 36 path: path.resolve(__dirname, './dist'), 37 filename: 'bundleSpec.js', 38 }, 39 target: 'node', 40 node: { 41 __dirname: false, 42 }, 43 module: { 44 rules: [ 45 { 46 test: /\.js$/, 47 loader: 'babel-loader', 48 exclude: /node_modules/, 49 }, 50 { 51 test: /\.tsx?$/, 52 use: 'ts-loader', 53 include: path.resolve(__dirname, './src'), 54 exclude: /node_modules/, 55 }, 56 { 57 test: /\.proto$/, 58 loader: 'proto-loader', 59 options: { 60 paths: [ 61 path.resolve(__dirname, '../../..'), 62 path.resolve(__dirname, '../../../external/protobuf/src'), 63 ], 64 }, 65 }, 66 { 67 test: /\.(pb|winscope)/, 68 loader: 'file-loader', 69 options: { 70 paths: [ 71 path.resolve(__dirname, './spec'), 72 ], 73 }, 74 }, 75 ], 76 }, 77 resolve: { 78 extensions: ['.tsx', '.ts', '.js', '.vue'], 79 alias: { 80 '@': path.resolve(__dirname, 'src'), 81 'WaylandSafePath': getWaylandSafePath(), 82 }, 83 modules: [ 84 'node_modules', 85 'kotlin_build', 86 path.resolve(__dirname, '../../..'), 87 ], 88 }, 89 resolveLoader: { 90 modules: [ 91 'node_modules', 92 path.resolve(__dirname, 'loaders'), 93 ], 94 }, 95 plugins: [ 96 new KotlinWebpackPlugin({ 97 src: [ 98 path.join(__dirname, '../../../platform_testing/libraries/flicker/' + 99 'src/com/android/server/wm/traces/common/'), 100 ], 101 output: 'kotlin_build', 102 moduleName: 'flicker', 103 librariesAutoLookup: true, 104 sourceMaps: true, 105 sourceMapEmbedSources: 'always', 106 verbose: true, 107 optimize: true, 108 }), 109 ], 110 devServer: { 111 historyApiFallback: true, 112 noInfo: true, 113 }, 114 performance: { 115 hints: false, 116 }, 117}; 118