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');
|
2018-04-25 23:52:44 +02:00
|
|
|
var JAVASCRIPT_DIR = SOURCE_DIR + '/javascript';
|
2017-01-06 20:49:37 +01:00
|
|
|
var BUILD_DIR = path.resolve(__dirname, 'build');
|
|
|
|
var NODEMODULES_DIR = path.resolve(__dirname, 'node_modules');
|
2016-11-11 19:47:20 +01:00
|
|
|
|
|
|
|
module.exports = {
|
2023-11-28 08:05:25 +01:00
|
|
|
mode: 'development',
|
2018-04-25 23:52:44 +02:00
|
|
|
context: SOURCE_DIR,
|
|
|
|
resolve: {
|
|
|
|
modules: [
|
|
|
|
path.resolve(JAVASCRIPT_DIR),
|
|
|
|
path.resolve('./node_modules')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
entry: {
|
|
|
|
app: './javascript/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
|
|
|
},
|
|
|
|
module: {
|
2018-04-25 23:52:44 +02:00
|
|
|
rules: [
|
2016-11-11 19:47:20 +01:00
|
|
|
{
|
|
|
|
// Ask webpack to check: If this file ends with .js, then apply some transforms
|
2017-01-06 20:49:37 +01:00
|
|
|
test: /\.jsx?$/,
|
2018-04-25 23:52:44 +02:00
|
|
|
loader: 'babel-loader',
|
2017-01-06 20:49:37 +01:00
|
|
|
include: [JAVASCRIPT_DIR],
|
2016-11-11 19:47:20 +01:00
|
|
|
},
|
|
|
|
{
|
2017-01-06 20:49:37 +01:00
|
|
|
test: /\.css$/,
|
2021-07-12 14:35:02 +02:00
|
|
|
use: ['style-loader', 'css-loader']
|
2016-11-12 00:08:06 +01:00
|
|
|
},
|
2016-11-11 19:47:20 +01:00
|
|
|
{
|
|
|
|
test: /\.png$/,
|
2021-07-12 14:35:02 +02:00
|
|
|
use: ["url-loader?limit=100000"]
|
2016-11-11 19:47:20 +01:00
|
|
|
},
|
2017-01-06 20:49:37 +01:00
|
|
|
{
|
|
|
|
test: /\.jpg$/,
|
|
|
|
loader: "file-loader"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
|
2021-07-12 14:35:02 +02:00
|
|
|
use: ['url-loader?limit=10000&mimetype=application/font-woff']
|
2017-01-06 20:49:37 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
|
2021-07-12 14:35:02 +02:00
|
|
|
use: ['url-loader?limit=10000&mimetype=application/octet-stream']
|
2017-01-06 20:49:37 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
|
2021-07-12 14:35:02 +02:00
|
|
|
use: ['file-loader']
|
2017-01-06 20:49:37 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
2021-07-12 14:35:02 +02:00
|
|
|
use: ['url-loader?limit=10000&mimetype=image/svg+xml']
|
2017-01-06 20:49:37 +01:00
|
|
|
}
|
2016-11-11 19:47:20 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
2018-04-25 23:52:44 +02:00
|
|
|
template: 'index.html'
|
2017-01-06 20:49:37 +01:00
|
|
|
}),
|
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')
|
|
|
|
}
|
|
|
|
}),
|
2021-07-12 14:35:02 +02:00
|
|
|
new CopyWebpackPlugin(
|
2017-01-06 20:49:37 +01:00
|
|
|
{
|
2021-07-12 14:35:02 +02:00
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: NODEMODULES_DIR + '/pdfjs-dist/build/pdf.worker.js',
|
|
|
|
to: 'bundle.worker.js'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
),
|
|
|
|
new CopyWebpackPlugin(
|
2017-05-02 19:19:57 +02:00
|
|
|
{
|
2021-07-12 14:35:02 +02:00
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: NODEMODULES_DIR + '/pdfjs-dist/cmaps',
|
|
|
|
to: 'cmaps'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
),
|
|
|
|
new CopyWebpackPlugin(
|
2018-04-25 23:52:44 +02:00
|
|
|
{
|
2021-07-12 14:35:02 +02:00
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'favicons',
|
|
|
|
to: 'favicons'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
2016-11-11 19:47:20 +01:00
|
|
|
]
|
2021-07-12 14:35:02 +02:00
|
|
|
}
|