forked from andy-lee-eng/perspective-viewer-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
81 lines (77 loc) · 2.83 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
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
const path = require("path");
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const pkg = require("./package.json");
const PREFIX = "perspective-viewer-";
const library = pkg.name;
const name = library.indexOf(PREFIX) == 0 ? library.substring(PREFIX.length) : library;
module.exports = {
entry: ["./src/js/plugin/plugin.js", "./src/themes/material.dark.less"],
devtool: "source-map",
mode: "development",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.html$/,
loader: "html-loader"
},
{
test: /\.less$/,
include: [path.resolve(__dirname, "src/less")],
use: [{loader: "css-loader"}, {loader: "less-loader"}]
},
{
test: /\.less$/,
include: [path.resolve(__dirname, "src/themes")],
use: [{loader: MiniCssExtractPlugin.loader}, {loader: "css-loader"}, {loader: "less-loader"}]
}
]
},
plugins: [new MiniCssExtractPlugin({filename: `${name}.plugin.dark.css`})],
optimization: {
minimizer: [
new UglifyJSPlugin({
uglifyOptions: {sourceMap: true, mangle: false}
})
]
},
output: {
filename: `${name}.plugin.js`,
library: library,
libraryTarget: "umd",
path: path.join(__dirname, "build")
},
devServer: {
contentBase: [
path.join(__dirname, "examples"),
path.resolve(__dirname, "node_modules/@finos/perspective/build"),
path.resolve(__dirname, "node_modules/@finos/perspective-viewer/build"),
path.resolve(__dirname, "node_modules/@finos/perspective-viewer-highcharts/build"),
path.resolve(__dirname, "node_modules/@finos/perspective-viewer-hypergrid/build"),
path.resolve(__dirname, "node_modules/@finos/perspective-viewer-d3fc/build")
],
proxy: {
"/template.plugin.js": {
target: `http://localhost:8080/${name}.plugin.js`,
ignorePath: true
},
"/template.plugin.dark.css": {
target: `http://localhost:8080/${name}.plugin.dark.css`,
ignorePath: true
}
}
}
};