2020-05-04 03:44:12 -07:00
|
|
|
const path = require('path');
|
2020-08-15 03:44:52 -07:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-08-16 11:24:45 -07:00
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2020-11-19 21:36:35 -07:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2020-05-29 14:32:45 -07:00
|
|
|
|
2020-11-20 20:07:37 -07:00
|
|
|
const Assets = [
|
|
|
|
'native-promise-only/npo.js',
|
|
|
|
'libarchive.js/dist/worker-bundle.js',
|
|
|
|
'libass-wasm/dist/js/subtitles-octopus-worker.js',
|
|
|
|
'libass-wasm/dist/js/subtitles-octopus-worker.data',
|
|
|
|
'libass-wasm/dist/js/subtitles-octopus-worker.wasm',
|
|
|
|
'libass-wasm/dist/js/subtitles-octopus-worker-legacy.js',
|
|
|
|
'libass-wasm/dist/js/subtitles-octopus-worker-legacy.data',
|
|
|
|
'libass-wasm/dist/js/subtitles-octopus-worker-legacy.js.mem',
|
|
|
|
'pdfjs-dist/build/pdf.worker.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
const LibarchiveWasm = [
|
|
|
|
'libarchive.js/dist/wasm-gen/libarchive.js',
|
|
|
|
'libarchive.js/dist/wasm-gen/libarchive.wasm'
|
|
|
|
];
|
|
|
|
|
2019-04-28 03:38:30 -07:00
|
|
|
module.exports = {
|
2020-05-04 03:44:12 -07:00
|
|
|
context: path.resolve(__dirname, 'src'),
|
2020-11-27 09:17:04 -07:00
|
|
|
target: 'browserslist',
|
2019-04-28 03:38:30 -07:00
|
|
|
resolve: {
|
|
|
|
modules: [
|
2020-05-04 03:44:12 -07:00
|
|
|
path.resolve(__dirname, 'node_modules')
|
2019-04-28 03:38:30 -07:00
|
|
|
]
|
2019-05-24 21:28:06 -07:00
|
|
|
},
|
2019-09-30 16:58:05 -07:00
|
|
|
plugins: [
|
2020-08-16 11:24:45 -07:00
|
|
|
new CleanWebpackPlugin(),
|
2020-11-19 21:36:35 -07:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: 'index.html',
|
|
|
|
template: 'index.html'
|
|
|
|
}),
|
2020-08-16 11:24:45 -07:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'themes/',
|
|
|
|
to: 'themes/'
|
2020-10-21 17:10:40 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'assets/**',
|
|
|
|
globOptions: {
|
2021-03-06 02:52:49 -07:00
|
|
|
dot: true,
|
2020-10-21 17:10:40 -07:00
|
|
|
ignore: ['**/css/*']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2021-03-06 02:51:55 -07:00
|
|
|
from: '*.*',
|
2020-10-21 17:10:40 -07:00
|
|
|
globOptions: {
|
2021-03-06 02:52:49 -07:00
|
|
|
dot: true,
|
2020-10-21 17:10:40 -07:00
|
|
|
ignore: ['**.js', '**.html']
|
|
|
|
}
|
2020-08-16 11:24:45 -07:00
|
|
|
}
|
|
|
|
]
|
2020-11-09 12:20:55 -07:00
|
|
|
}),
|
2020-11-20 20:07:37 -07:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: Assets.map(asset => {
|
|
|
|
return {
|
|
|
|
from: path.resolve(__dirname, `./node_modules/${asset}`),
|
|
|
|
to: path.resolve(__dirname, './dist/libraries')
|
|
|
|
};
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: LibarchiveWasm.map(asset => {
|
|
|
|
return {
|
|
|
|
from: path.resolve(__dirname, `./node_modules/${asset}`),
|
|
|
|
to: path.resolve(__dirname, './dist/libraries/wasm-gen')
|
|
|
|
};
|
|
|
|
})
|
2020-08-16 11:24:45 -07:00
|
|
|
})
|
2020-08-15 03:44:52 -07:00
|
|
|
],
|
|
|
|
output: {
|
2021-03-01 11:58:24 -07:00
|
|
|
filename: '[name].[contenthash].bundle.js',
|
2021-02-27 02:59:29 -07:00
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
publicPath: ''
|
2020-10-18 07:29:40 -07:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2020-10-18 12:37:54 -07:00
|
|
|
{
|
|
|
|
test: /\.(html)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'html-loader'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2020-11-27 15:46:16 -07:00
|
|
|
exclude: /node_modules[\\/](?!@uupaa[\\/]dynamic-import-polyfill|date-fns|epubjs|flv.js|libarchive.js)/,
|
2020-10-18 12:37:54 -07:00
|
|
|
use: [{
|
2020-12-03 14:49:37 -07:00
|
|
|
loader: 'babel-loader'
|
2020-10-18 12:37:54 -07:00
|
|
|
}]
|
|
|
|
},
|
2020-11-27 15:46:16 -07:00
|
|
|
/* modules that Babel breaks when transforming to ESM */
|
|
|
|
{
|
|
|
|
test: /node_modules[\\/](pdfjs-dist|xmldom)[\\/].*\.js$/,
|
|
|
|
use: [{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
plugins: [
|
|
|
|
'@babel/transform-modules-umd'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
2020-11-05 17:00:34 -07:00
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
config: {
|
|
|
|
path: __dirname
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'sass-loader'
|
|
|
|
]
|
|
|
|
},
|
2020-10-18 12:37:54 -07:00
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
config: {
|
|
|
|
path: __dirname
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|gif|svg)$/i,
|
|
|
|
use: ['file-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
|
|
use: [
|
|
|
|
'file-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(mp3)$/i,
|
|
|
|
use: ['file-loader']
|
|
|
|
},
|
2020-10-18 07:29:40 -07:00
|
|
|
{
|
|
|
|
test: require.resolve('jquery'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: ['$', 'jQuery']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-08-15 03:44:52 -07:00
|
|
|
}
|
2019-05-22 12:18:17 -07:00
|
|
|
};
|