1
0
mirror of https://github.com/kremalicious/blowfish.git synced 2024-12-28 23:57:52 +01:00
blowfish/webpack.common.config.js

75 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-05-05 13:34:21 +02:00
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
2019-05-17 00:19:00 +02:00
const CopyPlugin = require('copy-webpack-plugin')
2019-06-05 00:03:19 +02:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
2019-05-05 13:34:21 +02:00
2019-05-25 03:16:53 +02:00
const defaultInclude = [path.resolve(__dirname, 'src', 'renderer')]
2019-05-05 13:34:21 +02:00
2019-06-05 00:03:19 +02:00
const isDevelopment = process.env.NODE_ENV !== 'production'
2019-05-05 13:34:21 +02:00
module.exports = {
2019-06-05 00:03:19 +02:00
mode: isDevelopment ? 'development' : 'production',
2019-05-25 03:16:53 +02:00
entry: path.resolve(__dirname, 'src', 'renderer', 'index.js'),
2019-05-05 13:34:21 +02:00
output: {
2019-05-11 22:55:51 +02:00
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js',
2019-06-05 00:03:19 +02:00
publicPath: isDevelopment ? '/' : './'
2019-05-05 13:34:21 +02:00
},
module: {
rules: [
2019-06-05 00:03:19 +02:00
{
test: /\.(js|jsx)?$/,
use: ['babel-loader'],
include: defaultInclude
},
2019-05-05 13:34:21 +02:00
{
test: /\.css$/,
2019-09-08 21:47:57 +02:00
exclude: /\.module\.css$/,
2019-05-05 13:34:21 +02:00
use: ['style-loader', 'css-loader'],
include: defaultInclude
},
{
2019-09-08 21:47:57 +02:00
test: /\.module\.css$/,
2019-06-05 00:03:19 +02:00
include: defaultInclude,
loader: [
isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]__[local]___[hash:base64:5]'
},
localsConvention: 'camelCase',
2019-06-05 00:03:19 +02:00
sourceMap: isDevelopment
}
}
]
2019-05-05 13:34:21 +02:00
},
{
test: /\.(jpe?g|png|gif)$/,
use: ['file-loader?name=img/[name]__[hash:base64:5].[ext]'],
include: defaultInclude
},
{
2019-05-09 00:58:05 +02:00
test: /\.svg$/,
use: ['@svgr/webpack'],
include: defaultInclude
2019-05-05 13:34:21 +02:00
}
]
},
resolve: {
2019-09-09 01:33:27 +02:00
extensions: ['*', '.js', '.jsx', '.css']
2019-05-05 13:34:21 +02:00
},
target: 'electron-renderer',
2019-05-17 00:19:00 +02:00
plugins: [
new HtmlWebpackPlugin(),
2019-06-05 00:03:19 +02:00
new MiniCssExtractPlugin({
filename: isDevelopment ? '[name].css' : '[name].[hash].css',
chunkFilename: isDevelopment ? '[id].css' : '[id].[hash].css'
}),
2019-05-17 00:19:00 +02:00
new CopyPlugin([
2019-05-25 03:16:53 +02:00
{ from: './src/renderer/images/icon.*', to: './', flatten: true }
2019-05-17 00:19:00 +02:00
])
]
2019-05-05 13:34:21 +02:00
}