-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview-webpack.config.js
115 lines (106 loc) · 3.81 KB
/
view-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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const path = require('path');
const fs = require("fs");
const webpack = require("webpack");
const Visualizer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
// werbpack plugin
const { PowerBICustomVisualsWebpackPlugin } = require('powerbi-visuals-webpack-plugin');
// api configuration
const powerbiApi = require("powerbi-visuals-api");
// visual configuration json path
const pbivizPath = "./pbiviz.json";
const pbivizFile = require(path.join(__dirname, "./pbiviz.json"));
// the visual capabilities content
const capabilitiesPath = "./capabilities-view.json";
const capabilitiesFile = require(path.join(__dirname, capabilitiesPath));
// string resources
const resourcesFolder = path.join(".", "stringResources");
const localizationFolders = fs.existsSync(resourcesFolder) && fs.readdirSync(resourcesFolder);
const { merge } = require('webpack-merge');
const base = require('./base-webpack.config.js');
const GUID = 'charticulatorVisualCommunity_VIEW' || pbivizFile.visual.guid;
const NAME = 'CharticulatorCommunityVersionView' || pbivizFile.visual.name;
const DISPLAY_NAME = 'Charticulator Community Version (View)' || pbivizFile.visual.displayName;
const pluginLocation = './src/visualPluginView.ts';
const statsLocation = "../../view.webpack.statistics.html";
module.exports = merge(base, {
resolve: {
alias: {
'./Editor': './EditorViewMode',
}
},
mode: 'development',
devtool: 'inline-source-map',
devServer: {
static: {
directory: path.join(__dirname, '.tmp', 'drop'),
publicPath: '/assets'
},
devMiddleware: {
writeToDisk: true
},
hot: false
},
entry: {
"visual": pluginLocation
},
output: {
publicPath: '/assets',
path: path.join(__dirname, "/.tmp", "drop"),
library: GUID,
libraryTarget: 'var',
},
plugins: [
// visual plugin regenerates with the visual source, but it does not require relaunching dev server
new webpack.WatchIgnorePlugin({
paths: [
path.join(__dirname, pluginLocation),
"./.tmp/**/*.*"
]
}),
new Visualizer({
reportFilename: statsLocation,
openAnalyzer: false,
analyzerMode: `static`
}),
new ExtraWatchWebpackPlugin({
files: [
pbivizPath,
capabilitiesPath
]
}),
// custom visuals plugin instance with options
new PowerBICustomVisualsWebpackPlugin({
...pbivizFile,
visual: {
...pbivizFile.visual,
guid: GUID,
displayName: DISPLAY_NAME,
name: NAME
},
assets: {
icon: "assets/view_icon.png"
},
compression: 9,
capabilities: capabilitiesFile,
stringResources: localizationFolders && localizationFolders.map(localization => path.join(
resourcesFolder,
localization,
"resources.resjson"
)),
apiVersion: powerbiApi.version,
capabilitiesSchema: powerbiApi.schemas.capabilities,
pbivizSchema: powerbiApi.schemas.pbiviz,
stringResourcesSchema: powerbiApi.schemas.stringResources,
dependenciesSchema: powerbiApi.schemas.dependencies,
devMode: false,
generatePbiviz: true,
generateResources: false,
modules: true,
visualSourceLocation: "../src/visual",
pluginLocation: pluginLocation,
packageOutPath: path.join(__dirname, "dist"),
dropPath: path.join(__dirname, "/.tmp", "drop")
})
]
});