gengitkan/client/webpack.config.js

72 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-11-28 11:50:51 +01:00
const path = require('path');
// Plugins
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2019-12-13 14:21:20 +01:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
2019-11-28 11:50:51 +01:00
const env = process.env;
module.exports = {
mode: `${env.NODE_ENV ? env.NODE_ENV : 'production'}`,
entry: './src/index.js',
2019-12-13 14:21:20 +01:00
devtool: 'source-map',
2019-11-28 11:50:51 +01:00
output: {
2019-12-13 14:21:20 +01:00
filename: '[name].[hash:8].js',
sourceMapFilename: '[name].[hash:8].map',
2019-11-28 11:50:51 +01:00
path: path.join(__dirname, 'dist')
},
2019-11-28 14:12:48 +01:00
resolve: {
extensions: [ '.jsx', '.js' ],
},
2019-11-28 11:50:51 +01:00
module: {
rules: [{
2019-11-28 14:12:48 +01:00
test: /\.scss$/,
2019-11-28 11:50:51 +01:00
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {}
},
{
loader: "resolve-url-loader",
options: {}
},
{
loader: "sass-loader",
options: {
sourceMap: true,
sourceMapContents: false
}
}
]
},{
2019-12-05 16:23:20 +01:00
test: /\.(woff(2)?|ttf|eot|svg|png)(\?v=\d+\.\d+\.\d+)?$/,
2019-11-28 11:50:51 +01:00
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
2019-12-05 16:15:33 +01:00
outputPath: '/resources/'
2019-11-28 11:50:51 +01:00
}
}]
},{
2019-11-28 14:12:48 +01:00
test: /\.(js|jsx)$/,
2019-11-28 11:50:51 +01:00
exclude: /node_modules/,
2019-11-28 14:12:48 +01:00
use: ['babel-loader']
2019-11-28 11:50:51 +01:00
}]
},
plugins: [
new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "css/[id].css"
2019-12-13 14:21:20 +01:00
}),
new HtmlWebpackPlugin({
template: './src/index.html',
inject: false,
favicon: "./src/resources/favicon.png"
}),
new WebpackCleanupPlugin({
exclude: ['resources/logo.svg']
2019-11-28 11:50:51 +01:00
})
]
}