Upgrade pdfjs from 1.7.246 to 2.0.489

* Required web pack 2+ => updated to 3
* Add web pack-dev-server to be able to test worker.js stuff
This commit is contained in:
Johannes Zillmann
2018-04-25 23:52:44 +02:00
parent b1bcb5388d
commit 2869b5e5de
8 changed files with 12925 additions and 42 deletions

View File

@ -4,42 +4,32 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var SOURCE_DIR = path.resolve(__dirname, 'src');
var JAVASCRIPT_DIR = SOURCE_DIR + '/javascript';
var BUILD_DIR = path.resolve(__dirname, 'build');
var NODEMODULES_DIR = path.resolve(__dirname, 'node_modules');
var JAVASCRIPT_DIR = SOURCE_DIR + '/javascript';
module.exports = {
entry: JAVASCRIPT_DIR + '/index.jsx',
context: SOURCE_DIR,
resolve: {
modules: [
path.resolve(JAVASCRIPT_DIR),
path.resolve('./node_modules')
]
},
entry: {
app: './javascript/index.jsx'
},
output: {
path: BUILD_DIR,
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components')
}
},
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')]
},
module: {
// Special compilation rules
loaders: [
rules: [
{
// Ask webpack to check: If this file ends with .js, then apply some transforms
test: /\.jsx?$/,
// Transform it with babel
loader: 'babel',
// don't transform node_modules folder (which don't need to be compiled)
loader: 'babel-loader',
include: [JAVASCRIPT_DIR],
query: {
plugins: ['transform-runtime'],
presets: ['es2015', 'stage-0', 'react'],
}
},
{
test: /\.css$/,
@ -55,25 +45,25 @@ module.exports = {
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
loader: 'file-loader'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: SOURCE_DIR + '/index.html'
template: 'index.html'
}),
new webpack.DefinePlugin({
'process.env': {
@ -89,7 +79,13 @@ module.exports = {
]),
new CopyWebpackPlugin([
{
from: SOURCE_DIR + '/favicons',
from: NODEMODULES_DIR + '/pdfjs-dist/cmaps',
to: 'cmaps'
},
]),
new CopyWebpackPlugin([
{
from: 'favicons',
to: 'favicons'
},
])