forked from ebi-webcomponents/nightingale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
96 lines (91 loc) · 2.26 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
const fs = require("fs");
const path = require("path");
// const webpack = require("webpack");
const camelCase = require("camelcase");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const PACKAGE_ROOT_PATH = process.cwd();
const PKG_JSON = require(path.join(PACKAGE_ROOT_PATH, "package.json"));
const doesFileExists = path => {
try {
fs.statSync(path);
return true;
} catch (_) {
return false;
}
};
const config = {
entry: [
doesFileExists("./src/index.ts") ? "./src/index.ts" : "./src/index.js"
],
output: {
path: path.resolve(PACKAGE_ROOT_PATH, "dist"),
library: camelCase(PKG_JSON.name, { pascalCase: true }),
filename: `${PKG_JSON.name}.js`
},
target: "web",
devtool: "source-map",
resolve: {
extensions: [".js", ".ts"]
},
externals: {
d3: "d3",
litemol: "LiteMol",
"protvista-zoomable": "ProtvistaZoomable",
"protvista-track": "ProtvistaTrack",
"protvista-feature-adapter": "ProtvistaFeatureAdapter",
"protvista-utils": "ProtvistaUtils",
"protvista-sequence": "ProtvistaSequence"
},
plugins: [new CleanWebpackPlugin()],
module: {
rules: [
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader", options: { importLoaders: 1 } }
]
},
{
test: /\.(js|ts)$/,
use: {
loader: "babel-loader",
options: {
babelrc: false,
include: [
"src",
"../../node_modules/lit-html",
"../../node_modules/lit-element"
],
presets: [
[
"@babel/preset-env",
{
targets: {
ie: 11,
browsers: "last 2 versions"
},
modules: false
}
],
["@babel/preset-typescript"]
],
plugins: [
[
"@babel/plugin-transform-runtime",
{
regenerator: true
}
]
]
}
}
},
{
test: /\.svg$/,
loader: "svg-inline-loader?classPrefix"
}
]
}
};
module.exports = config;