-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwebpack.config.js
79 lines (75 loc) · 2.51 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
const path = require('path');
const buildDir = path.resolve(__dirname, 'build');
const CopyPlugin = require('copy-webpack-plugin');
const config = {
entry: {
// we could also generate a small JS library for every widget
// 'ImpactChart': './src/impact-chart.ts',
// 'FilterWidget': './src/filter-widget.ts',
// 'SectorDelete': './src/sector-list.ts',
'useeio_widgets': './src/main.ts',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: '[name].js',
path: buildDir + '/lib',
libraryTarget: 'var',
library: ['useeio' /*, '[name]' */],
},
plugins: [
new CopyPlugin({
patterns: [
{ from: 'src/**/*.html', to:path.resolve(__dirname, 'build','','[name][ext]')},
{ from: 'src/**/*.css', to: path.resolve(__dirname, 'build','','[name][ext]')},
{
from: 'node_modules/apexcharts/dist/apexcharts.min.js',
to: buildDir + '/lib/apexcharts.min.js',
toType: 'file'
},
{
from: 'node_modules/apexcharts/dist/apexcharts.css',
to: buildDir + '/lib/apexcharts.css',
toType: 'file'
},
/*
// We compile React into the generated library but we could
// also reference it as an external dependency (see below).
// This would be useful when React is already available in
// the page where the widgets whould be included.
{
from: 'node_modules/react/umd/react.production.min.js',
to: buildDir + '/lib/react.production.min.js', toType: 'file'
},
{
from: 'node_modules/react-dom/umd/react-dom.production.min.js',
to: buildDir + '/lib/react-dom.production.min.js', toType: 'file'
},
*/
]
}),
],
externals: {
"apexcharts": "apexcharts",
/*
"react": "React",
"react-dom": "ReactDOM",
*/
}
};
module.exports = (_env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'source-map';
}
return config;
};