2016-06-21 09:04:08 +12:00
|
|
|
|
2018-03-15 03:26:36 +13:00
|
|
|
import webpack from 'webpack'
|
2016-06-21 18:39:26 +12:00
|
|
|
import path from 'path'
|
2016-08-15 08:42:57 +12:00
|
|
|
import nodeExternals from 'webpack-node-externals'
|
2016-06-21 09:04:08 +12:00
|
|
|
|
2016-08-15 21:11:20 +12:00
|
|
|
let inProduction = process.env.NODE_ENV === 'production' || process.argv.indexOf('-p') !== -1
|
2016-06-21 09:04:08 +12:00
|
|
|
|
2016-08-15 08:42:57 +12:00
|
|
|
const bundleExtensionConfig = {
|
2016-06-21 18:39:26 +12:00
|
|
|
entry: {
|
2016-08-15 08:42:57 +12:00
|
|
|
eventPage: ['./src/eventPage'],
|
|
|
|
fimfic2epub: ['./src/main']
|
2016-06-21 18:39:26 +12:00
|
|
|
},
|
2016-08-15 08:42:57 +12:00
|
|
|
|
2016-06-21 18:39:26 +12:00
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '/'),
|
2018-03-13 10:03:58 +13:00
|
|
|
filename: './extension/build/[name].js'
|
2016-06-21 18:39:26 +12:00
|
|
|
},
|
2016-08-15 08:42:57 +12:00
|
|
|
|
2016-06-21 18:39:26 +12:00
|
|
|
module: {
|
2016-11-22 01:57:05 +13:00
|
|
|
rules: [
|
2016-06-21 18:39:26 +12:00
|
|
|
{
|
2016-08-29 22:12:04 +12:00
|
|
|
test: /\.js$/,
|
2017-04-12 08:00:45 +12:00
|
|
|
loader: 'babel-loader',
|
2016-08-29 22:12:04 +12:00
|
|
|
exclude: /node_modules/,
|
|
|
|
query: {
|
2016-08-15 21:11:20 +12:00
|
|
|
sourceMaps: true,
|
|
|
|
presets: ['es2015']
|
2016-06-21 18:39:26 +12:00
|
|
|
}
|
2016-06-21 21:32:49 +12:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
2016-11-22 01:57:05 +13:00
|
|
|
use: ['raw-loader', 'stylus-loader']
|
2016-06-21 18:39:26 +12:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2016-06-21 09:04:08 +12:00
|
|
|
|
2016-06-21 18:39:26 +12:00
|
|
|
resolve: {
|
2016-11-22 01:57:05 +13:00
|
|
|
extensions: ['.js', '.json', '.styl'],
|
2016-06-23 02:30:10 +12:00
|
|
|
modules: [
|
|
|
|
path.resolve('./src'),
|
|
|
|
'node_modules'
|
2018-03-13 10:03:58 +13:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
node: {
|
|
|
|
fs: 'empty'
|
2016-06-21 18:39:26 +12:00
|
|
|
},
|
2016-06-21 09:04:08 +12:00
|
|
|
|
2017-06-07 08:15:05 +12:00
|
|
|
externals: ['request'],
|
2016-08-15 08:42:57 +12:00
|
|
|
|
2018-03-13 10:03:58 +13:00
|
|
|
plugins: [
|
|
|
|
// new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)()
|
2018-03-15 03:26:36 +13:00
|
|
|
new webpack.NormalModuleReplacementPlugin(/font-awesome\/fonts\/fontawesome-webfont\.ttf/, './false')
|
2018-03-13 10:03:58 +13:00
|
|
|
],
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction
|
|
|
|
},
|
2018-03-13 23:11:44 +13:00
|
|
|
devtool: 'source-map',
|
2018-03-13 10:03:58 +13:00
|
|
|
mode: inProduction ? 'production' : 'development'
|
2016-08-15 08:42:57 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
const bundleNpmModuleConfig = {
|
|
|
|
entry: './src/FimFic2Epub',
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '/'),
|
2018-03-13 10:03:58 +13:00
|
|
|
filename: './dist/fimfic2epub.js',
|
2016-08-15 08:42:57 +12:00
|
|
|
libraryTarget: 'commonjs2'
|
|
|
|
},
|
|
|
|
|
|
|
|
target: 'node',
|
|
|
|
|
|
|
|
module: {
|
2016-11-22 01:57:05 +13:00
|
|
|
rules: [
|
2016-08-15 08:42:57 +12:00
|
|
|
{
|
2016-08-29 22:12:04 +12:00
|
|
|
test: /\.js$/,
|
2017-04-12 08:00:45 +12:00
|
|
|
loader: 'babel-loader',
|
2016-08-29 22:12:04 +12:00
|
|
|
exclude: /node_modules/,
|
|
|
|
query: {
|
2016-08-15 21:11:20 +12:00
|
|
|
sourceMaps: !inProduction,
|
2018-03-13 10:03:58 +13:00
|
|
|
presets: [['env', {
|
|
|
|
targets: {
|
|
|
|
node: '8.0.0'
|
|
|
|
}
|
|
|
|
}]]
|
2016-08-15 08:42:57 +12:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
2016-11-22 01:57:05 +13:00
|
|
|
use: ['raw-loader', 'stylus-loader']
|
2016-08-15 08:42:57 +12:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2016-06-21 09:04:08 +12:00
|
|
|
|
2016-08-15 08:42:57 +12:00
|
|
|
resolve: {
|
2016-11-22 01:57:05 +13:00
|
|
|
extensions: ['.js', '.json', '.styl'],
|
2016-08-15 08:42:57 +12:00
|
|
|
modules: [
|
|
|
|
path.resolve('./src'),
|
|
|
|
'node_modules'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-03-13 10:03:58 +13:00
|
|
|
node: {
|
|
|
|
__dirname: false
|
|
|
|
},
|
|
|
|
|
2018-03-15 03:26:36 +13:00
|
|
|
externals: [nodeExternals({whitelist: ['es6-event-emitter', /^babel-runtime/]}), {
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.ttf': 'require.resolve(\'font-awesome/fonts/fontawesome-webfont.ttf\')'
|
|
|
|
}],
|
2016-08-15 08:42:57 +12:00
|
|
|
|
|
|
|
plugins: [],
|
2018-03-13 10:03:58 +13:00
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction
|
|
|
|
},
|
|
|
|
devtool: 'nosources-source-map',
|
|
|
|
mode: inProduction ? 'production' : 'development'
|
2016-06-21 09:04:08 +12:00
|
|
|
}
|
2016-08-15 08:42:57 +12:00
|
|
|
|
2018-03-15 03:26:36 +13:00
|
|
|
const bundleNpmBinaryConfig = {
|
|
|
|
entry: './src/cli',
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '/'),
|
|
|
|
filename: './build/fimfic2epub.js'
|
|
|
|
},
|
|
|
|
|
|
|
|
target: 'node',
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
query: {
|
|
|
|
sourceMaps: !inProduction,
|
|
|
|
presets: [['env', {
|
|
|
|
targets: {
|
|
|
|
node: '8.0.0'
|
|
|
|
}
|
|
|
|
}]]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
|
|
|
use: ['raw-loader', 'stylus-loader']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.json', '.styl'],
|
|
|
|
modules: [
|
|
|
|
path.resolve('./src'),
|
|
|
|
'node_modules'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
node: {
|
|
|
|
__dirname: false
|
|
|
|
},
|
|
|
|
|
|
|
|
externals: [nodeExternals(), {
|
|
|
|
'./FimFic2Epub': 'require(\'../dist/fimfic2epub\')',
|
|
|
|
'../package.json': 'require(\'../package.json\')',
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.ttf': 'require.resolve(\'font-awesome/fonts/fontawesome-webfont.ttf\')'
|
|
|
|
}],
|
|
|
|
|
|
|
|
plugins: [],
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
concatenateModules: inProduction,
|
|
|
|
minimize: inProduction
|
|
|
|
},
|
|
|
|
devtool: false,
|
|
|
|
mode: inProduction ? 'production' : 'development'
|
|
|
|
}
|
|
|
|
|
|
|
|
const bundleStaticNpmModuleConfig = {
|
|
|
|
entry: './src/cli',
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '/'),
|
|
|
|
filename: './build/fimfic2epub-static.js'
|
|
|
|
},
|
|
|
|
|
|
|
|
target: 'node',
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
query: {
|
|
|
|
sourceMaps: !inProduction,
|
|
|
|
presets: [['env', {
|
|
|
|
targets: {
|
|
|
|
node: '9.0.0'
|
|
|
|
}
|
|
|
|
}]]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
|
|
|
use: ['raw-loader', 'stylus-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ttf$/,
|
|
|
|
use: 'binary-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.json', '.styl'],
|
|
|
|
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
|
|
|
|
]
|