-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.js
77 lines (75 loc) · 2.34 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
const path = require('path');
const webpack = require('webpack');
const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const sharedConfig = {
module: {
rules: [
{
test: /\.(html|ico)$/,
use: [{
loader: 'file-loader',
options: { name: '[name].[ext]' }
}]
},
{
test: /\.(s*)css$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { sourceMap: false } },
{ loader: 'sass-loader', options: { sourceMap: false } },
]
}
]
},
plugins: [
new ExtraWatchWebpackPlugin({
files: [
'./build/**/*.scss',
'./build/**/*.html'
],
}),
new webpack.DefinePlugin({
__BUILD_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true),
__RCSB_MOLSTAR_VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./package.json').version), true),
'process.env.DEBUG': JSON.stringify(process.env.DEBUG)
}),
new MiniCssExtractPlugin({ filename: 'rcsb-molstar.css' })
],
resolve: {
modules: [
'node_modules',
path.resolve(__dirname, 'build/src/')
],
fallback: {
fs: false,
vm: false,
buffer: false,
crypto: require.resolve('crypto-browserify'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify')
}
},
watchOptions: {
aggregateTimeout: 750
},
devtool: false
};
module.exports = [
{
entry: path.resolve(__dirname, `build/src/viewer/index.js`),
output: {
library: 'rcsbMolstar',
libraryTarget: 'umd',
filename: `rcsb-molstar.js`,
path: path.resolve(__dirname, `build/dist/viewer`)
},
...sharedConfig
},{
entry: path.resolve(__dirname, `build/src/viewer/assets.js`),
output: {
path: path.resolve(__dirname, `build/dist/viewer`)
},
...sharedConfig
}
];