-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
37 lines (32 loc) · 879 Bytes
/
webpack.config.js
File metadata and controls
37 lines (32 loc) · 879 Bytes
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
const path = require('path');
const fs = require('fs');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CSS_FILE_NAME = process.env.npm_package_dsccViz_cssFile;
const cssFilePath = path.join('src', CSS_FILE_NAME);
const plugins = [];
let body = '<script src="main.js"></script>';
if (fs.existsSync(cssFilePath)) {
body = body + '\n<link rel="stylesheet" href="index.css">';
plugins.push(new CopyWebpackPlugin([{from: cssFilePath, to: '.'}]));
}
const iframeHTML = `
<!doctype html>
<html><body>
${body}
</body></html>
`;
fs.writeFileSync(path.resolve(__dirname, 'dist', 'vizframe.html'), iframeHTML);
module.exports = [
{
mode: 'development',
entry: './src/index.js',
devServer: {
contentBase: './dist',
},
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: plugins,
},
];