-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.base.config.js
137 lines (135 loc) · 3.47 KB
/
webpack.base.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
const path = require("path");
const webpack = require("webpack");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const StringReplacePlugin = require("string-replace-webpack-plugin");
const npmPkg = require("./package.json");
const shebangRemovalLoader = {
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /^#!.*$/m,
replacement: function(match, p1, offset, string) {
return "";
}
}
]
})
};
module.exports = {
context: path.resolve(__dirname),
entry: {
Pvjs: ["babel-polyfill", "./esnext/Pvjs.js"],
"pvjs.vanilla": ["babel-polyfill", "./esnext/pvjs.vanilla.js"]
/*
"pvjs.jquery": ["babel-polyfill", "./esnext/pvjs.jquery.js"]
"wikipathways-pvjs.webcomponent": [
"babel-polyfill",
"./esnext/wikipathways-pvjs.webcomponent.js"
]
//*/
//cli: ["babel-polyfill", "./esnext/cli.js"]
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "dist"),
library: "Pvjs",
libraryExport: "Pvjs",
libraryTarget: "umd"
},
resolve: {
extensions: [
".webpack.js",
".web.js",
".ts",
".tsx",
".js",
".jsx",
".json"
]
},
module: {
rules: [
/*
// Create an external stylesheet rather than inlined to support Angular CLI users
// In Angular CLI, all styles must be specified in the styles property of a component
// See: https://github.com/angular/angular-cli/issues/1459
// Note: the typestyles will still be imported fine since they are not css files
// Angular CLI users should add 'dist/style.css' into their component styles
// TODO: Add an example of this in the README
{
test: /\.css$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
use: ["css-loader", "postcss-loader"]
})
},
//*/
/*
{
test: /\.css$/,
exclude: /node_modules/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
importLoaders: 1
}
},
{
loader: "postcss-loader"
}
]
},
//*/
{
test: /\.css$/,
/*
exclude: /node_modules/,
include: [
path.resolve(__dirname, "esnext"),
path.resolve(__dirname, "node_modules/kaavio"),
path.resolve(__dirname, "../kaavio/"),
path.resolve(__dirname, "node_modules/loaders.css"),
path.resolve(__dirname, "node_modules/bridgedb"),
path.resolve(__dirname, "node_modules/react-select"),
],
//*/
use: [{ loader: "to-string-loader" }, { loader: "css-loader" }]
},
{
test: /\.json$/,
exclude: /node_modules/,
use: "json-loader"
},
{
test: /\.[jt]sx?$/,
use: ["source-map-loader", shebangRemovalLoader],
enforce: "pre",
exclude: [/lodash/, /react-dom/]
},
{
test: require.resolve("react-dom"),
exclude: /node_modules/,
use: [
{
loader: "expose-loader",
options: "ReactDOM"
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
version: npmPkg.version
}),
//new webpack.IgnorePlugin(/source-map-support/),
new MiniCssExtractPlugin({
filename: "style.css",
ignoreOrder: false
})
]
};