Scoped babel packages and stricter proposals
[incubator-annotator.git] / webpack.config.js
1 /**
2 * @license
3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 * use this file except in compliance with the License. You may obtain a copy of
5 * the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 * License for the specific language governing permissions and limitations under
13 * the License.
14 */
15
16 /* eslint-env node */
17 /* eslint-disable import/unambiguous */
18
19 const path = require('path');
20 const webpack = require('webpack');
21
22 module.exports = {
23 context: path.resolve(__dirname),
24 entry: {
25 demo: './demo/index.js',
26 },
27 devServer: {
28 contentBase: path.resolve(__dirname),
29 host: 'localhost',
30 port: 8080,
31 hot: true,
32 },
33 devtool: 'inline-source-map',
34 module: {
35 rules: [
36 {
37 test: /\.js$/,
38 exclude: /node_modules/,
39 use: {
40 loader: 'babel-loader',
41 options: {
42 plugins: [
43 // Add polyfills without pollution and externalize helpers.
44 '@babel/transform-runtime',
45 ],
46 presets: [
47 [
48 '@babel/env',
49 {
50 modules: false,
51 shippedProposals: true,
52 targets: {
53 browsers: ['defaults'],
54 },
55 },
56 ],
57 ],
58 },
59 },
60 },
61 ],
62 },
63 resolve: {
64 alias: {
65 '@annotator': path.resolve(__dirname, 'packages/'),
66 },
67 },
68 plugins: [
69 new webpack.HotModuleReplacementPlugin(),
70 new webpack.NamedModulesPlugin(),
71 new webpack.optimize.CommonsChunkPlugin({
72 name: 'common',
73 minChunks: module => {
74 return module.context && /node_modules/.test(module.context);
75 },
76 }),
77 new webpack.optimize.CommonsChunkPlugin({
78 name: 'manifest',
79 minChunks: Infinity,
80 }),
81 new webpack.optimize.ModuleConcatenationPlugin(),
82 ],
83 output: {
84 filename: '[name].js',
85 publicPath: '/',
86 },
87 };