Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/assets/jbrowse/webpack.config.js
1677 views
1
/* eslint-env node */
2
require('babel-polyfill')
3
4
const DojoWebpackPlugin = require("dojo-webpack-plugin")
5
const CopyWebpackPlugin = require("copy-webpack-plugin")
6
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
7
const CleanWebpackPlugin = require('clean-webpack-plugin');
8
9
const path = require("path")
10
const glob = require('glob')
11
const webpack = require("webpack")
12
13
// if JBROWSE_BUILD_MIN env var is 1 or true, then we also minimize the JS
14
// and forego generating source maps
15
const DEBUG = ! [1,'1','true'].includes(process.env.JBROWSE_BUILD_MIN)
16
17
var webpackConf = {
18
entry: {
19
main: "src/JBrowse/main",
20
browser: "src/JBrowse/standalone"
21
},
22
plugins: [
23
new CleanWebpackPlugin(['dist']),
24
25
new DojoWebpackPlugin({
26
loaderConfig: require("./build/dojo-loader-config"),
27
environment: {
28
dojoRoot: process.env.JBROWSE_PUBLIC_PATH || "./dist/"
29
},
30
buildEnvironment: {
31
dojoRoot: "node_modules/"
32
},
33
locales: ["en"],
34
loader: path.resolve('./build/dojo-webpack-plugin-loader/dojo/dojo.js')
35
}),
36
37
new CopyWebpackPlugin([{
38
context: "node_modules",
39
from: "dojo/resources/blank.gif",
40
to: "dojo/resources"
41
}]),
42
43
new webpack.NormalModuleReplacementPlugin(
44
/^dojox\/gfx\/renderer!/,
45
"dojox/gfx/canvas"
46
),
47
48
new webpack.NormalModuleReplacementPlugin(/^dojo\/text!/, function(data) {
49
data.request = data.request.replace(/^dojo\/text!/, "!!raw-loader!");
50
}),
51
52
new webpack.NormalModuleReplacementPlugin(
53
/^css!/, function(data) {
54
data.request = data.request.replace(/^css!/, "!style-loader!css-loader!sass-loader!")
55
}
56
),
57
],
58
module: {
59
rules: [
60
{
61
test: /\.js$/,
62
exclude: /node_modules\/(?!(quick-lru|@gmod\/indexedfasta|@gmod\/tabix|@gmod\/tribble-index|@gmod\/bgzf-filehandle))/,
63
use: {
64
loader: 'babel-loader',
65
options: {
66
presets: ['es2015-without-strict'],
67
plugins: ['transform-async-to-generator','transform-es2015-classes'],
68
cacheDirectory: true
69
}
70
}
71
},
72
{
73
test: /src\/JBrowse\/main.js|src\/JBrowse\/standalone.js|tests\/js_tests\/main.js/,
74
use: [{ loader: path.resolve('build/glob-loader.js') }]
75
},
76
{
77
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/,
78
use: 'url-loader?limit=10000',
79
},
80
{
81
// regex replace all JBrowse plugin JS to just remove any use of dojo/domReady!
82
test: filepath => filepath.indexOf(__dirname+'/plugins')===0 && /\.js$/.test(filepath),
83
use: {
84
loader: 'regexp-replace-loader',
85
options: {
86
match: {
87
pattern: '["`\']dojo/domReady!?["\'`]\s*',
88
flags: 'g'
89
},
90
replaceWith: '"JBrowse/has"'
91
}
92
}
93
}
94
]
95
},
96
output: {
97
filename: '[name].bundle.js',
98
chunkFilename: '[name].bundle.js',
99
path: path.resolve(__dirname, 'dist'),
100
publicPath: process.env.JBROWSE_PUBLIC_PATH || 'dist/'
101
},
102
resolveLoader: {
103
modules: ["node_modules"]
104
},
105
resolve: {
106
symlinks: false
107
}
108
}
109
110
if (DEBUG) {
111
webpackConf.mode = 'development'
112
webpackConf.entry.run_jasmine = 'tests/js_tests/main.js'
113
webpackConf.plugins.push( new webpack.optimize.AggressiveMergingPlugin() )
114
} else {
115
webpackConf.mode = 'production'
116
webpackConf.plugins.push( new UglifyJsPlugin())
117
}
118
119
module.exports = webpackConf
120
121