cacert-fomanticui-css/webpack.common.js

72 lines
1.8 KiB
JavaScript
Raw Normal View History

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({
filename: '[name].[contenthash].css'
}),
new OptimizeCSSAssetsPlugin({})
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.[hash].js'
},
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'
}
]
},
};