-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
147 lines (144 loc) · 3.92 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const Dotenv = require('dotenv-webpack');
module.exports = (env, argv) => {
const devMode = argv.mode !== 'production';
return {
context: __dirname, // to automatically find tsconfig.json
devtool: 'source-map',
entry: {
'lara-app': './src/lara-app/index.tsx',
'mobile-app': './src/mobile-app/index.tsx',
'sensor-demo': './src/sensor-demo/index.tsx',
'shared': './src/shared/index.tsx',
'authoring-app': './src/authoring-app/index.tsx'
},
mode: 'development',
output: {
filename: '[name]/assets/index.[hash].js'
},
performance: { hints: false },
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
use: [
{
loader: 'tslint-loader',
options: {}
}
]
},
{
test: /\.tsx?$/,
loader: 'ts-loader',
},
{
test: /^(?!.*module).*\.(sa|sc|c)ss$/i,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader'
]
},
{
test: /\.module\.(sa|sc|c)ss$/i,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]-[local]-vortex'
},
sourceMap: true,
importLoaders: 1
}
},
'postcss-loader',
'sass-loader'
]
},
{
test: /\.(png|woff|woff2|eot|ttf)$/,
loader: 'url-loader',
options: {
limit: 8192,
publicPath: '../../'
}
},
{
test: /\.svg$/,
oneOf: [
{
// Do not apply SVGR import in (S)CSS files.
issuer: /\.scss$/,
use: 'url-loader'
},
{
issuer: /\.tsx?$/,
loader: '@svgr/webpack'
}
]
}
]
},
resolve: {
extensions: [ '.ts', '.tsx', '.js' ]
},
stats: {
// suppress "export not found" warnings about re-exported types
warningsFilter: /export .* was not found in/
},
plugins: [
new MiniCssExtractPlugin({
filename: devMode ? "[name]/assets/index.css" : "[name]/assets/index.[hash].css"
}),
new HtmlWebpackPlugin({
chunks: [],
filename: 'index.html',
template: 'src/index.html'
}),
new HtmlWebpackPlugin({
chunks: ['lara-app'],
filename: 'lara-app/index.html',
template: 'src/lara-app/index.html'
}),
new HtmlWebpackPlugin({
chunks: ['mobile-app'],
filename: 'mobile-app/index.html',
template: 'src/mobile-app/index.html'
}),
new HtmlWebpackPlugin({
chunks: ['sensor-demo'],
filename: 'sensor-demo/index.html',
template: 'src/sensor-demo/index.html'
}),
new HtmlWebpackPlugin({
chunks: ['shared'],
filename: 'shared/index.html',
template: 'src/shared/index.html'
}),
new HtmlWebpackPlugin({
chunks: ['authoring-app'],
filename: 'authoring-app/index.html',
template: 'src/authoring-app/index.html'
}),
new CopyWebpackPlugin([
{from: 'src/lara-app/public', to: 'lara-app/'}
]),
new CopyWebpackPlugin([
{from: 'src/mobile-app/public', to: 'mobile-app/'}
]),
new CopyWebpackPlugin([
{from: 'src/data', to: 'data/'}
]),
new Dotenv()
]
};
};