You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.2 KiB
84 lines
2.2 KiB
import { Configuration } from 'webpack'
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
import postcssPresetEnv from 'postcss-preset-env'
|
|
// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
|
|
|
import c from './config/config.json'
|
|
|
|
const config: Configuration = {
|
|
mode: 'development',
|
|
devtool: 'eval-source-map',
|
|
entry: {
|
|
app: `${__dirname}/src/app.tsx`
|
|
},
|
|
output: {
|
|
path: `${__dirname}/dist`,
|
|
publicPath: '/',
|
|
filename: '[name].js',
|
|
},
|
|
optimization: {
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
},
|
|
},
|
|
devServer: {
|
|
contentBase: `${__dirname}/dist`,
|
|
historyApiFallback: true,
|
|
before: app => {
|
|
app.get('/config.json', (_, res) => {
|
|
res.json(c)
|
|
})
|
|
},
|
|
},
|
|
resolve: {
|
|
extensions: ['.ts', '.tsx', '.js'],
|
|
alias: {
|
|
src: `${__dirname}/src`,
|
|
}
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts(x?)$/,
|
|
exclude: /node_modules/,
|
|
use: 'ts-loader',
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
},
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
options: {
|
|
plugins: [
|
|
postcssPresetEnv({
|
|
stage: 2,
|
|
}),
|
|
]
|
|
}
|
|
}
|
|
],
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
title: 'Flexor',
|
|
hash: true,
|
|
template: 'src/index.ejs',
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].css',
|
|
}),
|
|
// new BundleAnalyzerPlugin(),
|
|
],
|
|
}
|
|
|
|
export default config
|