forked from avontd2868/PowerBI-visuals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
177 lines (166 loc) · 6.48 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var webpack = require("webpack");
var path = require("path");
var gutils = require("gulp-util");
var ConcatDtsPlugin = require("./build/webpack/ConcatDtsPlugin.js");
var SkipUnchangedAssetsPlugin = require("./build/webpack/SkipUnchangedAssetsPlugin.js");
var globEntries = require('./build/webpack/relativeGlobEntries');
var progressHandler = require("./build/webpack/progressHandler.js");
var SpritesmithPlugin = require('webpack-spritesmith');
var options = require('./build/options');
var DEBUG = true;
var optionalPlugins = [];
var buildEntries = {};
var testFolder = "tests";
//TODO: join this logic with the same one in Tests/webpack.config.js
if (!options.buildWithoutTests) {
// generate separate entry for every test file
buildEntries = globEntries('./**/*Tests.ts', path.join(__dirname, "./src/Clients/PowerBIVisualsTests"), testFolder);
// add externals, helpers and utils
buildEntries[path.join(testFolder, "testsInfra")] = path.join(__dirname, './src/Clients/PowerBIVisualsTests/testsInfra.ts');
}
buildEntries["CustomVisuals"] = ['./src/Clients/CustomVisuals/module.ts'];
buildEntries["VisualsCommon"] = ['./src/Clients/VisualsCommon/module.ts'];
buildEntries["VisualsData"] = ['./src/Clients/VisualsData/module.ts'];
buildEntries["VisualsExtensibility"] = ['./src/Clients/VisualsExtensibility/module.ts'];
buildEntries["Visuals"] = ['./src/Clients/Visuals/module.ts'];
buildEntries["PowerBIVisualsPlayground"] = ['./src/Clients/PowerBIVisualsPlayground/module.ts'];
buildEntries["VisualsContracts"] = ['./src/Clients/VisualsContracts/module.ts'];
buildEntries["powerbi-visuals"] = [
'./src/Clients/VisualsContracts/module.ts',
'./src/Clients/VisualsCommon/module.ts',
'./src/Clients/VisualsData/module.ts',
'./src/Clients/VisualsExtensibility/module.ts',
'./src/Clients/Visuals/module.ts',
];
if (!DEBUG) {
optionalPlugins.push(new webpack.optimize.UglifyJsPlugin({
// include: /\.min\.js$/,
minimize: true,
compress: {
warnings: false
},
sourceMap: true
}));
}
if (!options.noProgress) {
optionalPlugins.push(new webpack.ProgressPlugin(progressHandler));
}
var TSFilesPattern = /.*(([^d])|([^\.]d))\.ts$/i;
module.exports = {
debug: DEBUG,
devtool: '#cheap-module-source-map', // map producing: http://webpack.github.io/docs/configuration.html#devtool
cache: true,
entry: buildEntries,
output: {
filename: DEBUG ? '[name].js' : '[name].min.js',
// filename: '[name].js',
path: path.resolve(__dirname, "lib"),
sourceMapFilename: "[file].map",
chunkFilename: "[id].[chunkhash].chunk.js",
// publicPath: "/assets/"
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.svg']
},
resolveLoader: {
modulesDirectories: ["./build/webpack/", "node_modules"]
},
module: {
// enable tslinting
preLoaders: [
{ test: TSFilesPattern, loader: "tslint", exclude: /node_modules/ }
],
loaders: [
{
test: TSFilesPattern, loader: 'imports', exclude: /node_modules/,
query: {
jsCommon: ">window.jsCommon",
powerbi: ">window.powerbi",
powerbitests: ">window.powerbitests",
InJs: ">window.InJs",
debug: ">window.debug",
jasmine: ">window.jasmine",
Microsoft: ">window.Microsoft"
}
},
{
test: TSFilesPattern, loader: 'ts-loader', exclude: /node_modules/,
},
{
test: /.*\.d\.ts$/i, loader: "FileToAssetLoader", exclude: /node_modules/,
},
{
test: /(\.less$)|(\.css$)/,
loader: ExtractTextPlugin.extract("css-loader?-url&sourceMap!less-loader?relativeUrls&noIeCompat")
},
// { test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/, loader: 'file?name=generated/[name].[ext]' },
],
},
tslint: {
emitErrors: true,
},
ts: {
configFileName: 'tsconfig_.json', // wrong name in order to do not load tsconfig files at all
compilerOptions: {
target: "ES5",
module: "commonjs",
sourceMap: true, // this option enables inlining .ts sources into .map files
declaration: true,
experimentalDecorators: true // PowerBIVisualsTests/extensibility/decorators/VisualPluginTests.ts uses decorator
},
silent: true
},
stats: {
// see supported StatsOptions: https://github.com/shama/webpack-stream/blob/d2276e9b14bdb719a5085041bfadc189dc72ce3a/index.js#L10
colors: true,
// produced assets info is useful in watch mode only
assets: false,
assetsByChunkName: false,
cached: false,
cachedAssets: false,
hash: false,
timings: false,
version: false,
children: false,
chunkModules: false,
modules: false,
chunks: false,
},
plugins: [
new ConcatDtsPlugin(
{
chunks: [
"CustomVisuals",
"VisualsCommon",
"VisualsData",
"VisualsExtensibility",
"Visuals",
"VisualsContracts",
"powerbi-visuals",
],
// remove reference tags
// TODO: remove copyrights
transformation: function (dtsFileBuffer) {
return new Buffer(dtsFileBuffer.toString().replace(/\/\/\/\s*<reference path.*\/>\s/g, ""), "utf8");
}
}
),
new ExtractTextPlugin("[name].css"),
new SpritesmithPlugin({
src: {
cwd: path.resolve(__dirname, 'src/Clients/Visuals/images'),
glob: './sprite-src/*.png'
},
target: {
// image: path.resolve(__dirname, 'src/Clients/Visuals/images/visuals.sprites.png'),
image: path.resolve(__dirname, 'lib/images/visuals.sprites.png'),
css: path.resolve(__dirname, 'src/Clients/Visuals/styles/sprites.less')
},
apiOptions: {
cssImageRef: "../images/visuals.sprites.png"
}
}),
new SkipUnchangedAssetsPlugin()
].concat(optionalPlugins)
}