pdf-to-markdown/webpack.config.js

91 lines
2.9 KiB
JavaScript
Raw Normal View History

2017-01-06 20:49:37 +01:00
var path = require('path');
var webpack = require('webpack');
2016-11-11 19:47:20 +01:00
var HtmlWebpackPlugin = require('html-webpack-plugin');
2017-01-06 20:49:37 +01:00
var CopyWebpackPlugin = require('copy-webpack-plugin');
var SOURCE_DIR = path.resolve(__dirname, 'src');
var BUILD_DIR = path.resolve(__dirname, 'build');
var NODEMODULES_DIR = path.resolve(__dirname, 'node_modules');
var JAVASCRIPT_DIR = SOURCE_DIR + '/javascript';
2016-11-11 19:47:20 +01:00
module.exports = {
2017-01-06 20:49:37 +01:00
entry: JAVASCRIPT_DIR + '/index.jsx',
2016-11-11 19:47:20 +01:00
output: {
2017-01-06 20:49:37 +01:00
path: BUILD_DIR,
filename: 'bundle.js'
2016-11-11 19:47:20 +01:00
},
resolve: {
extensions: ['', '.js'],
2016-11-11 19:47:20 +01:00
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: [
{
// Ask webpack to check: If this file ends with .js, then apply some transforms
2017-01-06 20:49:37 +01:00
test: /\.jsx?$/,
2016-11-11 19:47:20 +01:00
// Transform it with babel
loader: 'babel',
// don't transform node_modules folder (which don't need to be compiled)
2017-01-06 20:49:37 +01:00
include: [JAVASCRIPT_DIR],
query: {
plugins: ['transform-runtime'],
presets: ['es2015', 'stage-0', 'react'],
}
2016-11-11 19:47:20 +01:00
},
{
2017-01-06 20:49:37 +01:00
test: /\.css$/,
loader: "style-loader!css-loader"
2016-11-12 00:08:06 +01:00
},
2016-11-11 19:47:20 +01:00
{
test: /\.png$/,
loader: "url-loader?limit=100000"
},
2017-01-06 20:49:37 +01:00
{
test: /\.jpg$/,
loader: "file-loader"
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
}
2016-11-11 19:47:20 +01:00
]
},
plugins: [
new HtmlWebpackPlugin({
2017-01-06 20:49:37 +01:00
template: SOURCE_DIR + '/index.html'
}),
2017-01-09 21:24:12 +01:00
new webpack.DefinePlugin({
'process.env': {
'version': JSON.stringify(process.env.npm_package_version),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
2017-01-06 20:49:37 +01:00
new CopyWebpackPlugin([
{
from: NODEMODULES_DIR + '/pdfjs-dist/build/pdf.worker.js',
to: 'bundle.worker.js'
},
])
2016-11-11 19:47:20 +01:00
]
}