This repository has been archived by the owner on Dec 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
/
webpack.config.js
101 lines (97 loc) · 2.31 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const webpack = require('webpack');
const path = require('path');
const lodash = require('lodash');
const infernoBabelConfig = getBabelConfig();
infernoBabelConfig.plugins.push('inferno');
const preactBabelConfig = getBabelConfig();
preactBabelConfig.presets.splice(0, 1);
preactBabelConfig.plugins.push(['transform-react-jsx', {pragma: 'h'}])
module.exports = {
entry: __dirname + '/src/single-spa-examples.js',
output: {
path: process.cwd() + '/build',
filename: '[name].js',
publicPath: '/build/',
},
devtool: 'inline-source-map',
devServer: {
port: 8080,
publicPath: '/build/',
contentBase: './',
historyApiFallback: {
index: '200.html',
},
},
resolve: {
modules: [
"node_modules",
path.resolve(__dirname, "./"),
],
alias: {
'single-spa': path.resolve(__dirname, 'node_modules/single-spa/lib/single-spa.js'),
},
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /inferno.+\.js$/,
loader: 'babel-loader',
query: infernoBabelConfig,
},
{
test: /preact.+\.js$/,
loader: 'babel-loader',
query: preactBabelConfig,
},
{
test: /\.html$/,
exclude: /node_modules|svelte/,
loader: 'html-loader',
},
{
test: /\.js$/,
exclude: /node_modules|inferno|preact/,
loader: 'babel-loader',
query: getBabelConfig(),
},
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
},
{
test: /svelte.+\.html$/,
loader: 'svelte-loader',
},
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: module => module.context && module.context.indexOf('node_modules') !== -1
}),
new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)esm5/, path.join(__dirname, './src')),
],
};
function getBabelConfig() {
return {
presets: [
'react',
['babel-preset-env', {
targets: {
"browsers": ["last 2 versions"],
},
}],
],
plugins: [
'transform-object-rest-spread',
'transform-class-properties',
'syntax-dynamic-import',
'transform-function-bind',
],
};
}