system-praktyk-front/webpack.config.js

64 lines
1.6 KiB
JavaScript

const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { GenerateSW } = require('workbox-webpack-plugin');
const HtmlWebpackPlugin = require("html-webpack-plugin")
const config = {
entry: {
main: ['./src/index.tsx'],
},
output: {
path: path.resolve('./build/'),
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
'@': path.resolve(__dirname, './src'),
}
},
module: {
rules: [{
test: /\.s[ac]ss$/,
use: ["style-loader", "css-loader?sourceMap", "sass-loader?sourceMap"]
}, {
test: /\.css$/,
use: ["style-loader", "css-loader"]
}, {
test: /\.tsx?$/,
use: 'babel-loader',
exclude: /node_modules/
}, {
test: /\.(png|svg|jpg|gif)$/,
use: 'file-loader',
}, {
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: 'file-loader'
}]
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({ // Also generate a test.html
filename: 'index.html',
template: 'public/index.html'
}),
],
devServer: {
contentBase: path.resolve("./public/"),
port: 3000
},
optimization: {
usedExports: true
}
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'inline-source-map';
}
process.env.BABEL_ENV = argv.mode || 'production';
return config;
};