fimfic2epub/webpack.config.babel.js

101 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-06-21 09:04:08 +12:00
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, '/'),
filename: './extension/[name].js'
},
2016-08-15 08:42:57 +12:00
2016-06-21 18:39:26 +12:00
module: {
loaders: [
{
test: /\.js$/, loader: 'babel', 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$/,
loader: 'raw-loader!stylus-loader'
2016-06-21 18:39:26 +12:00
}
],
noParse: [
/[\/\\]node_modules[\/\\]tidy-html5[\/\\]tidy\.js$/
]
},
2016-06-21 09:04:08 +12:00
2016-06-21 18:39:26 +12:00
resolve: {
2016-06-21 21:32:49 +12:00
extensions: ['', '.js', '.json', '.styl'],
2016-06-23 02:30:10 +12:00
modules: [
path.resolve('./src'),
'node_modules'
2016-08-22 08:21:49 +12:00
],
alias: {
fs: require.resolve('./src/false.js')
}
2016-06-21 18:39:26 +12:00
},
2016-06-21 09:04:08 +12:00
2016-08-24 02:32:55 +12:00
externals: ['request', 'tidy-html5'],
2016-08-15 08:42:57 +12:00
2016-06-21 18:39:26 +12:00
plugins: [],
2016-08-15 21:11:20 +12:00
devtool: 'source-map',
debug: true,
uglify: inProduction
2016-08-15 08:42:57 +12:00
}
const bundleNpmModuleConfig = {
entry: './src/FimFic2Epub',
output: {
path: path.join(__dirname, '/'),
filename: './fimfic2epub.js',
libraryTarget: 'commonjs2'
},
target: 'node',
module: {
loaders: [
{
test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: {
2016-08-15 21:11:20 +12:00
sourceMaps: !inProduction,
presets: ['es2015']
2016-08-15 08:42:57 +12:00
}
},
{
test: /\.styl$/,
loader: 'raw-loader!stylus-loader'
}
],
noParse: [
/[\/\\]node_modules[\/\\]tidy-html5[\/\\]tidy\.js$/
]
},
2016-06-21 09:04:08 +12:00
2016-08-15 08:42:57 +12:00
resolve: {
extensions: ['', '.js', '.json', '.styl'],
modules: [
path.resolve('./src'),
'node_modules'
]
},
externals: [nodeExternals(), 'exports?tidy_html5!tidy-html5'],
plugins: [],
2016-08-15 21:11:20 +12:00
devtool: 'source-map',
debug: true,
uglify: inProduction
2016-06-21 09:04:08 +12:00
}
2016-08-15 08:42:57 +12:00
export default [bundleExtensionConfig, bundleNpmModuleConfig]