blob: 31d79ca816eb11f7cdfaab5db1cb4e3bed86905f [file] [log] [blame]
Pablo Gamito3f239132020-07-17 12:33:32 +01001/*
2 * Copyright 2020, 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
17'use strict';
18
19const webpack = require('webpack');
20const { merge } = require('webpack-merge');
21const path = require('path');
22const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
23const commonConfig = require('./webpack.config.common');
24const environment = require('./env/dev.env');
25
26const webpackConfig = merge(commonConfig, {
27 mode: 'development',
28 devtool: 'cheap-module-eval-source-map',
29 output: {
30 path: path.resolve(__dirname, 'dist'),
31 publicPath: '/',
32 filename: 'js/[name].bundle.js',
33 chunkFilename: 'js/[id].chunk.js'
34 },
35 optimization: {
36 runtimeChunk: 'single',
37 splitChunks: {
38 chunks: 'all'
39 }
40 },
41 module: {
42 rules: [
43 // Enable sourcemaps for Kotlin code, source-map-loader should be configured
44 {
45 test: /\.js$/,
46 include: path.resolve(__dirname, './kotlin_build'),
47 exclude: [
48 /kotlin\.js$/, // Kotlin runtime doesn't have sourcemaps at the moment
49 ],
50 use: ['source-map-loader'],
51 enforce: 'pre'
52 },
53 ]
54 },
55 plugins: [
56 new webpack.EnvironmentPlugin(environment),
57 new webpack.HotModuleReplacementPlugin(),
58 new FriendlyErrorsPlugin()
59 ],
60 devServer: {
61 compress: true,
62 historyApiFallback: true,
63 hot: true,
64 open: true,
65 overlay: true,
66 port: 8080,
67 stats: {
68 normal: true
69 }
70 }
71});
72
73module.exports = webpackConfig;