forked from eScholarship/jschol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
71 lines (69 loc) · 1.86 KB
/
webpack.common.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
const webpack = require("webpack");
const _ = require('lodash');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
///////////////////////////////////////////////////////////////////////////////////////////////////
// read package.json and get dependencies' package ids
function getNPMPackageIds() {
var packageManifest = {};
try {
packageManifest = require('./package.json');
} catch (e) {
// does not have a package.json manifest
}
return _.keys(packageManifest.dependencies) || []
}
module.exports = {
cache: true,
bail: false,
entry: {
app: './app/jsx/App.jsx'
},
output: {
filename: '[name]-bundle-[chunkhash].js',
path: __dirname + '/app/js',
publicPath: "/js/"
},
optimization: {
splitChunks: {
chunks: 'all',
name: true
}
},
plugins: [
// Provides jQuery globally to all browser modules, so we can use jquery plugins like Trumbowyg
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ["*-bundle*.js*"]
}),
// Generates manifest.json so app can know the exact names of files for cache-busting
new ManifestPlugin(),
new ProgressPlugin( (percent, message) =>
process.stdout.write(" [" + Math.round(percent*100) + "%] " + message + " \r")
)
],
resolve: {
alias: {
'pdfjs-lib': __dirname + '/node_modules/pdfjs-embed2/src/pdf.js'
},
},
module: {
rules: [{
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /pdfjs-embed2.*\.js$/,
exclude: /src\/core\/(glyphlist|unicode)/,
loader: 'babel-loader'
}]
},
performance : {
hints : false
}
}