blob: ff31ff361ff9ac735c8518cb54c41a134293126b [file] [log] [blame]
Vishnu Nair46babab2017-12-19 15:15:30 -08001/*
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
Vishnu Nairfe159592020-05-19 21:44:19 -070017const fs = require('fs');
Vishnu Nair46babab2017-12-19 15:15:30 -080018var path = require('path')
19var webpack = require('webpack')
Adrian Roos77d8a392017-12-29 16:20:58 +010020var HtmlWebpackPlugin = require('html-webpack-plugin')
21var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
Vishnu Nair46babab2017-12-19 15:15:30 -080022
Vishnu Nair92dccb52020-01-27 15:00:13 -080023function getWaylandSafePath() {
Vishnu Nairfe159592020-05-19 21:44:19 -070024 waylandPath = path.resolve(__dirname, '../../../vendor/google_arc/libs/wayland_service');
25 if (fs.existsSync(waylandPath)) {
26 return waylandPath;
Vishnu Nair92dccb52020-01-27 15:00:13 -080027 }
Vishnu Naircbddf0a2020-03-16 16:33:08 -070028 return path.resolve(__dirname, 'src/stubs');
Vishnu Nair92dccb52020-01-27 15:00:13 -080029}
30
Vishnu Nair46babab2017-12-19 15:15:30 -080031module.exports = {
32 entry: './src/main.js',
33 output: {
34 path: path.resolve(__dirname, './dist'),
Vishnu Nair46babab2017-12-19 15:15:30 -080035 filename: 'build.js'
36 },
37 module: {
38 rules: [
39 {
40 test: /\.vue$/,
41 loader: 'vue-loader',
42 options: {
43 loaders: {
44 }
45 // other vue-loader options go here
46 }
47 },
48 {
49 test: /\.js$/,
50 loader: 'babel-loader',
51 exclude: /node_modules/
52 },
53 {
54 test: /\.proto$/,
55 loader: 'proto-loader',
56 options: {
Vishnu Nair62d93dd2018-02-06 14:40:42 -080057 paths: [
58 path.resolve(__dirname, '../../..'),
59 path.resolve(__dirname, '../../../external/protobuf/src')
60 ]
Vishnu Nair46babab2017-12-19 15:15:30 -080061 }
62 },
63 {
64 test: /\.(png|jpg|gif|svg)$/,
65 loader: 'file-loader',
66 options: {
67 name: '[name].[ext]?[hash]'
68 }
69 }
70 ]
71 },
72 resolve: {
Vishnu Nair92dccb52020-01-27 15:00:13 -080073 alias: {
74 WaylandSafePath: getWaylandSafePath(),
Vishnu Nair92dccb52020-01-27 15:00:13 -080075 },
Vishnu Nairf60b79f2017-12-28 11:18:46 -080076 modules: [
77 'node_modules',
78 path.resolve(__dirname, '../../..')
79 ],
Vishnu Nair46babab2017-12-19 15:15:30 -080080 },
81 resolveLoader: {
82 modules: [
83 'node_modules',
84 path.resolve(__dirname, 'loaders')
85 ]
86 },
87 devServer: {
88 historyApiFallback: true,
89 noInfo: true
90 },
91 performance: {
92 hints: false
93 },
94 devtool: '#eval-source-map'
95}
96
Adrian Roos77d8a392017-12-29 16:20:58 +010097var prod = (process.env.NODE_ENV === 'production');
98
99if (prod) {
Vishnu Nair46babab2017-12-19 15:15:30 -0800100 module.exports.devtool = '#source-map'
101 // http://vue-loader.vuejs.org/en/workflow/production.html
102 module.exports.plugins = (module.exports.plugins || []).concat([
103 new webpack.DefinePlugin({
104 'process.env': {
105 NODE_ENV: '"production"'
106 }
107 }),
108 new webpack.optimize.UglifyJsPlugin({
109 sourceMap: true,
110 compress: {
111 warnings: false
112 }
113 }),
114 new webpack.LoaderOptionsPlugin({
115 minimize: true
116 })
117 ])
118}
Adrian Roos77d8a392017-12-29 16:20:58 +0100119
120module.exports.plugins = (module.exports.plugins || []).concat([
121 new HtmlWebpackPlugin({
122 inlineSource: prod ? '.(js|css)' : false,
123 template: 'src/index_template.html'
124 }),
125 new HtmlWebpackInlineSourcePlugin(),
126]);