-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.ui.js
103 lines (99 loc) · 2.79 KB
/
webpack.config.ui.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
const dev = process.env.NODE_ENV === 'dev';
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const tsconfig = require('./tsconfig.json');
// Main entry point
const indexConfig = {
template: './src/demos/ui/index.html',
inject: 'body',
baseHref: './'
};
const webpackConfig = {
mode: 'development',
// How source maps are generated : style of source mapping
devtool: dev ? 'eval-cheap-module-source-map' : false,
// Development server configuration
devServer: {
historyApiFallback: true,
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000
},
// Where webpack looks to start building the bundle
entry: {
'ui': './src/demos/ui/main.ts' // Demo app entry point
},
// How the different types of modules within a project will be treated
module: {
rules: [
{ test: /\.ts|\.tsx$/, loader: 'ts-loader' },
// All files with a '.scss' extension will be handled by sass-loader
{
test: /\.(scss)$/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
// })
},
// CSS loader
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(woff|woff2|svg|eot|ttf)$/,
loader: 'file-loader'
},
{
test: /\.(jp[e]?g|png)$/,
loader: 'file-loader'
}
]
},
// Configure how modules are resolved
resolve: {
extensions: ['.ts', '.tsx', '.js', '.scss', '.css'],
modules: [
path.resolve('./src'),
path.resolve('./src/packages'),
path.resolve('./node_modules')
],
alias: Object.keys(tsconfig.compilerOptions.paths).reduce((aliases, aliasName) => {
aliases[aliasName] = path.resolve(__dirname, `src/${tsconfig.compilerOptions.paths[aliasName][0]}`);
return aliases;
}, {})
},
// How and where webpack should output bundles, assets and anything else
output: {
path: path.resolve(__dirname, './dist/demo/ui'),
filename: '[name].bundle.js'
},
// What bundle information gets displayed
stats: {
warnings: false
},
// Target a specific environment (cf. doc)
target: 'web',
// Configure whether to polyfill or mock certain Node.js globals and modules
node: {
__dirname: false
},
// Customize the webpack build process with additionals plugins
plugins: [
new HtmlWebpackPlugin(indexConfig),
new CopyWebpackPlugin({
patterns: [
{
from: './src/demos/ui/images/*',
flatten: true,
to: './images/'
}
]
})
]
};
// Export the config
module.exports = webpackConfig;