-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
65 lines (61 loc) · 1.79 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
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const copyright = 'Copyright (c) 2016-2019 Gonçalo Baltazar <[email protected]>\n\n'
+ 'Source Code on GitHub: https://github.com/goncalomb/p3js\n\n'
+ 'P3JS is released under the terms of the MIT License.\n'
+ 'See LICENSE.txt for details.';
function createBundleConfig(entry, filename, library, plugins) {
const output = {
path: path.join(__dirname, 'www'),
filename: `static/p3js/${filename}`,
};
if (library) {
output.library = library;
}
const config = {
mode: 'none',
entry,
output,
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['@babel/preset-env'],
},
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
},
],
},
};
if (plugins) {
config.plugins = plugins;
}
return config;
}
module.exports = [
createBundleConfig('./src/p3js/', 'p3js-bundle.js', 'p3js', [
new webpack.BannerPlugin(
`P3JS Bundle\n\nP3 CPU Assembler and Simulator.\nExposes 'window.p3js'.\n\n${copyright}`,
),
]),
createBundleConfig('./src/p3js-dom/', 'p3js-dom-bundle.js', ['p3js', 'dom'], [
new webpack.BannerPlugin(
`P3JS-DOM Bundle\n\nDOM components for P3JS (p3js.dom).\n\n${copyright}`,
),
new CopyWebpackPlugin([
{ from: 'src/p3js-dom/main.css', to: 'static/p3js/p3js-dom.css' },
]),
]),
createBundleConfig('./src/p3js-web/', 'p3js-web-bundle.js', null, [
new webpack.BannerPlugin(
`P3JS-WEB Bundle\n\nWeb interface for P3JS.\nExposes 'window.p3sim', an instance of 'p3js.SimulatorWithIO'.\n\n${copyright}`,
),
]),
];