2021-05-25 11:42:43 +12:00
|
|
|
import webpack from 'webpack'
|
2019-10-08 21:44:04 +13:00
|
|
|
import path from 'path'
|
|
|
|
import nodeExternals from 'webpack-node-externals'
|
|
|
|
|
2019-10-08 22:31:42 +13:00
|
|
|
const inProduction = process.env.NODE_ENV === 'production' || process.argv.indexOf('-p') !== -1
|
2019-10-08 21:44:04 +13:00
|
|
|
|
|
|
|
const bundleExtensionConfig = {
|
|
|
|
entry: {
|
|
|
|
eventPage: ['./src/eventPage'],
|
|
|
|
fimfic2epub: ['regenerator-runtime/runtime', './src/main']
|
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
2020-08-10 20:53:32 +12:00
|
|
|
path: path.join(__dirname, '/extension/build'),
|
|
|
|
filename: './[name].js'
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [['@babel/env', {
|
|
|
|
targets: {
|
|
|
|
browsers: ['chrome 50', 'firefox 47']
|
2021-05-25 11:42:43 +12:00
|
|
|
}
|
2019-10-08 21:44:04 +13:00
|
|
|
}]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
2021-05-25 11:42:43 +12:00
|
|
|
use: ['stylus-loader'],
|
|
|
|
type: 'asset/source'
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ttf$/,
|
|
|
|
use: 'binary-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2021-05-25 11:42:43 +12:00
|
|
|
target: 'web',
|
|
|
|
|
2019-10-08 21:44:04 +13:00
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.json', '.styl'],
|
|
|
|
modules: [
|
|
|
|
path.resolve('./src'),
|
|
|
|
'node_modules'
|
2021-05-25 11:42:43 +12:00
|
|
|
],
|
|
|
|
fallback: {
|
|
|
|
url: false,
|
|
|
|
fs: false,
|
|
|
|
zlib: require.resolve('browserify-zlib'),
|
|
|
|
buffer: require.resolve('buffer/'),
|
|
|
|
assert: require.resolve('assert/'),
|
|
|
|
stream: require.resolve('stream-browserify')
|
|
|
|
},
|
|
|
|
alias: {
|
|
|
|
path: false
|
|
|
|
}
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
|
2020-03-15 06:15:02 +13:00
|
|
|
externals: ['node-fetch'],
|
2019-10-08 21:44:04 +13:00
|
|
|
|
|
|
|
plugins: [
|
|
|
|
// new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)()
|
2021-05-25 11:42:43 +12:00
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
Buffer: ['buffer', 'Buffer']
|
|
|
|
})
|
2019-10-08 21:44:04 +13:00
|
|
|
],
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction,
|
|
|
|
splitChunks: {
|
2019-10-09 20:52:53 +13:00
|
|
|
chunks: 'all',
|
|
|
|
automaticNameDelimiter: '_'
|
2019-10-08 21:44:04 +13:00
|
|
|
}
|
|
|
|
},
|
|
|
|
devtool: 'source-map',
|
|
|
|
mode: inProduction ? 'production' : 'development'
|
|
|
|
}
|
|
|
|
|
|
|
|
const bundleNpmModuleConfig = {
|
|
|
|
entry: './src/FimFic2Epub',
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '/'),
|
|
|
|
filename: './dist/fimfic2epub.js',
|
|
|
|
libraryTarget: 'commonjs2'
|
|
|
|
},
|
|
|
|
|
|
|
|
target: 'node',
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
sourceMaps: !inProduction,
|
|
|
|
presets: [['@babel/env', {
|
|
|
|
targets: {
|
2020-10-20 00:49:00 +13:00
|
|
|
node: '10.0.0'
|
2019-10-08 21:44:04 +13:00
|
|
|
}
|
|
|
|
}]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
2021-05-25 11:42:43 +12:00
|
|
|
use: ['stylus-loader'],
|
|
|
|
type: 'asset/source'
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ttf$/,
|
|
|
|
use: 'binary-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.json', '.styl', '.node'],
|
|
|
|
modules: [
|
|
|
|
path.resolve('./src'),
|
|
|
|
'node_modules'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
node: {
|
|
|
|
__dirname: false
|
|
|
|
},
|
|
|
|
|
2020-08-10 19:44:28 +12:00
|
|
|
externals: [nodeExternals({ allowlist: [/^babel-runtime/, /fontawesome-webfont\.ttf/] })],
|
2019-10-08 21:44:04 +13:00
|
|
|
|
|
|
|
plugins: [],
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction
|
|
|
|
},
|
|
|
|
devtool: 'nosources-source-map',
|
|
|
|
mode: inProduction ? 'production' : 'development'
|
|
|
|
}
|
|
|
|
|
|
|
|
const bundleNpmBinaryConfig = {
|
|
|
|
entry: './src/cli',
|
|
|
|
|
|
|
|
output: {
|
2020-08-10 20:53:32 +12:00
|
|
|
path: path.join(__dirname, '/build'),
|
|
|
|
filename: './fimfic2epub.js'
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
|
|
|
|
target: 'node',
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
sourceMaps: !inProduction,
|
|
|
|
presets: [['@babel/env', {
|
|
|
|
targets: {
|
2021-05-25 11:42:43 +12:00
|
|
|
node: '14.0.0'
|
2019-10-08 21:44:04 +13:00
|
|
|
}
|
|
|
|
}]]
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 11:42:43 +12:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
|
|
|
use: ['stylus-loader'],
|
|
|
|
type: 'asset/resource'
|
2019-10-08 21:44:04 +13:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
2021-05-25 11:42:43 +12:00
|
|
|
extensions: ['.js', '.json', '.node', '.styl'],
|
2019-10-08 21:44:04 +13:00
|
|
|
modules: [
|
|
|
|
path.resolve('./src'),
|
|
|
|
'node_modules'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
node: {
|
|
|
|
__dirname: false
|
|
|
|
},
|
|
|
|
|
2020-08-10 21:34:53 +12:00
|
|
|
externals: [nodeExternals(), {
|
|
|
|
'./FimFic2Epub': 'require(\'../dist/fimfic2epub\')',
|
|
|
|
'../package.json': 'require(\'../package.json\')'
|
|
|
|
}],
|
|
|
|
|
2019-10-08 21:44:04 +13:00
|
|
|
plugins: [],
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction
|
|
|
|
},
|
|
|
|
devtool: false,
|
|
|
|
mode: inProduction ? 'production' : 'development'
|
|
|
|
}
|
|
|
|
|
|
|
|
const bundleStaticNpmModuleConfig = {
|
|
|
|
entry: './src/cli',
|
|
|
|
|
|
|
|
output: {
|
2020-08-10 20:53:32 +12:00
|
|
|
path: path.join(__dirname, '/build'),
|
|
|
|
filename: './fimfic2epub.js'
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
|
|
|
|
target: 'node',
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
2021-05-25 11:42:43 +12:00
|
|
|
use: ['stylus-loader'],
|
|
|
|
type: 'asset/source'
|
2019-10-08 21:44:04 +13:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ttf$/,
|
|
|
|
use: 'binary-loader'
|
2020-01-16 23:41:22 +13:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
2020-08-10 21:34:53 +12:00
|
|
|
loader: 'node-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]'
|
|
|
|
}
|
2019-10-08 21:44:04 +13:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.json', '.styl', '.node'],
|
|
|
|
modules: [
|
|
|
|
path.resolve('./bin'),
|
|
|
|
'node_modules'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
node: {
|
|
|
|
__dirname: false
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [],
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction
|
|
|
|
},
|
|
|
|
devtool: false,
|
|
|
|
mode: inProduction ? 'production' : 'development'
|
|
|
|
}
|
|
|
|
|
|
|
|
export default [
|
|
|
|
bundleExtensionConfig,
|
|
|
|
bundleNpmModuleConfig,
|
|
|
|
bundleNpmBinaryConfig,
|
|
|
|
bundleStaticNpmModuleConfig
|
|
|
|
]
|