-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
89 lines (82 loc) · 2.23 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
const webpack = require("webpack");
const path = require("path");
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 config = {
entry: ["./src/index.js"],
output: {
path: path.resolve(PACKAGE_ROOT_PATH, "dist"),
library: camelCase(PKG_JSON.name, { pascalCase: true }),
filename: `${PKG_JSON.name}-${PKG_JSON.version}.js`
},
target: "web",
devtool: "source-map",
resolve: {
extensions: [".js"]
},
externals: {
d3: "d3",
"resize-observer-polyfill": "ResizeObserver"
},
plugins: [new CleanWebpackPlugin([path.join(PACKAGE_ROOT_PATH, "dist")])],
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 = config;