-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
84 lines (77 loc) · 2.38 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
const path = require('path');
// const webpack = require('webpack');
// const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PACKAGE_ROOT_PATH = process.cwd();
const PKG_JSON = require(path.join(PACKAGE_ROOT_PATH, "package.json"));
const componentConfig = {
entry: path.resolve(__dirname, `src/web-component/index.js`),
output: { filename: `${PKG_JSON.name}-component-build-${PKG_JSON.version}.js`, path: path.resolve(__dirname, `build/`) },
target: "web",
devtool: "source-map",
resolve: {
extensions: [".js"]
},
externals: {
"PdbTopologyViewerPlugin": "PdbTopologyViewerPlugin"
},
// plugins: [new CleanWebpackPlugin([path.join(PACKAGE_ROOT_PATH, "build")])],
module: {
rules: [
{
test: /\.css$/,
use: [
"style-loader",
{ loader: "css-loader", options: { importLoaders: 1 } }
]
},
{
test: /.(jpg|jpeg|png|svg)$/,
use: ['url-loader'],
},
{
test: /\.(js)$/,
exclude: function excludeCondition(path){
const nonEs5SyntaxPackages = [
'lit-element',
'lit-html'
]
// DO transpile these packages
if (nonEs5SyntaxPackages.some( pkg => path.match(pkg))) {
return false;
}
// Ignore all other modules that are in node_modules
if (path.match(/node_modules\\/)) { return true; }
else return false;
},
use: {
loader: "babel-loader",
options: {
babelrc: false,
presets: [
[
"@babel/preset-env",
{
targets: {
ie: 11,
browsers: "last 2 versions"
},
modules: false
}
]
],
plugins: [
[
"@babel/plugin-transform-runtime",
{
regenerator: true
}
]
]
}
}
}
]
}
}
module.exports = [componentConfig];