2020-05-31 16:06:14 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const path = require('path');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
|
|
const devMode = process.env.NODE_ENV !== 'production';
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
|
|
app: './src/index.js',
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
title: 'CAcert',
|
|
|
|
template: './src/index.html',
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
2020-05-31 17:23:48 +00:00
|
|
|
filename: 'cacert-theme.css'
|
2020-05-31 16:06:14 +00:00
|
|
|
}),
|
|
|
|
new OptimizeCSSAssetsPlugin({})
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2020-05-31 17:23:48 +00:00
|
|
|
filename: 'cacert-theme.js'
|
2020-05-31 16:06:14 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.jsx'],
|
|
|
|
alias: {
|
|
|
|
'../../theme.config$': path.join(__dirname, 'cacert-theme/theme.config')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
use: [
|
|
|
|
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
|
|
'css-loader',
|
|
|
|
'postcss-loader',
|
|
|
|
'sass-loader'
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
'css-loader',
|
|
|
|
'less-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.jpe?g$|\.git$|\.ico$|\.png$|\.svg$/,
|
|
|
|
use: 'file-loader?name=[name].[ext]?[hash]'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
|
|
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
|
|
loader: 'file-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.otf(\?.*)?$/,
|
|
|
|
use: 'file-loader?name=/fonts/[name].[ext]&mimetype=application/font-otf'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
};
|