blob: 677391e3c917fb7db6337c0978b1c8c95989dee6 [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
17var path = require('path')
18var webpack = require('webpack')
Adrian Roos77d8a392017-12-29 16:20:58 +010019var HtmlWebpackPlugin = require('html-webpack-plugin')
20var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
Vishnu Nair46babab2017-12-19 15:15:30 -080021
22module.exports = {
23 entry: './src/main.js',
24 output: {
25 path: path.resolve(__dirname, './dist'),
Vishnu Nair46babab2017-12-19 15:15:30 -080026 filename: 'build.js'
27 },
28 module: {
29 rules: [
30 {
31 test: /\.vue$/,
32 loader: 'vue-loader',
33 options: {
34 loaders: {
35 }
36 // other vue-loader options go here
37 }
38 },
39 {
40 test: /\.js$/,
41 loader: 'babel-loader',
42 exclude: /node_modules/
43 },
44 {
45 test: /\.proto$/,
46 loader: 'proto-loader',
47 options: {
Vishnu Nair62d93dd2018-02-06 14:40:42 -080048 paths: [
49 path.resolve(__dirname, '../../..'),
50 path.resolve(__dirname, '../../../external/protobuf/src')
51 ]
Vishnu Nair46babab2017-12-19 15:15:30 -080052 }
53 },
54 {
55 test: /\.(png|jpg|gif|svg)$/,
56 loader: 'file-loader',
57 options: {
58 name: '[name].[ext]?[hash]'
59 }
60 }
61 ]
62 },
63 resolve: {
Vishnu Nairf60b79f2017-12-28 11:18:46 -080064 modules: [
65 'node_modules',
66 path.resolve(__dirname, '../../..')
67 ],
Vishnu Nair46babab2017-12-19 15:15:30 -080068 },
69 resolveLoader: {
70 modules: [
71 'node_modules',
72 path.resolve(__dirname, 'loaders')
73 ]
74 },
75 devServer: {
76 historyApiFallback: true,
77 noInfo: true
78 },
79 performance: {
80 hints: false
81 },
82 devtool: '#eval-source-map'
83}
84
Adrian Roos77d8a392017-12-29 16:20:58 +010085var prod = (process.env.NODE_ENV === 'production');
86
87if (prod) {
Vishnu Nair46babab2017-12-19 15:15:30 -080088 module.exports.devtool = '#source-map'
89 // http://vue-loader.vuejs.org/en/workflow/production.html
90 module.exports.plugins = (module.exports.plugins || []).concat([
91 new webpack.DefinePlugin({
92 'process.env': {
93 NODE_ENV: '"production"'
94 }
95 }),
96 new webpack.optimize.UglifyJsPlugin({
97 sourceMap: true,
98 compress: {
99 warnings: false
100 }
101 }),
102 new webpack.LoaderOptionsPlugin({
103 minimize: true
104 })
105 ])
106}
Adrian Roos77d8a392017-12-29 16:20:58 +0100107
108module.exports.plugins = (module.exports.plugins || []).concat([
109 new HtmlWebpackPlugin({
110 inlineSource: prod ? '.(js|css)' : false,
111 template: 'src/index_template.html'
112 }),
113 new HtmlWebpackInlineSourcePlugin(),
114]);