assemble/webpack.config.js

100 lines
2.6 KiB
JavaScript
Raw Normal View History

2024-01-28 03:50:31 +03:00
const {resolve} = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
//const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isProduction = process.argv[process.argv.indexOf('--mode') + 1] === 'production';
module.exports = {
entry:[
resolve(__dirname,"ui/index.js")
],
output:{
path: resolve(__dirname,"./public/assets"),
filename: "bundle.js",
chunkFilename: isProduction ? "[contenthash:16].js" : "[name]-[contenthash:5].js",
2024-01-28 21:17:45 +03:00
publicPath: "/assets/",
2024-01-28 03:50:31 +03:00
clean: true
},
resolve: {
extensions: [
'.js',
'.jsx',
'.ts',
'.tsx',
'.css',
'.scss',
'.jpg',
'.jpeg',
'.png',
'.svg'
]
},
optimization:{
splitChunks:{
chunks: 'async'
},
chunkIds: "size",
moduleIds: "size",
mangleExports: "size"
},
stats: {
logging: 'warn',
},
cache: {
type: 'filesystem',
cacheLocation: resolve(__dirname, '.cache'),
cacheDirectory: resolve(__dirname, '.cache')
},
2024-01-28 21:17:45 +03:00
devtool: 'source-map',
2024-01-28 03:50:31 +03:00
target:"web",
module: {
rules: [{
test: /\.(jpe?g|png|svg|web[pm])$/i,
exclude: /node_modules/,
2024-01-28 21:17:45 +03:00
loader: "file-loader",
2024-01-28 03:50:31 +03:00
options: {
name: 'images/[name].[ext]',
},
},{
test: /.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
"@babel/preset-env",
{
"targets": {
"browsers": ["last 2 Chrome versions"]
}
}
],
"@babel/preset-react"
],
plugins: [
"@babel/plugin-transform-runtime",
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
}
},{
test: /\.s[ac]ss$|\.css$/i,
exclude: /node_modules/,
use: [
"style-loader",
"css-loader",
"sass-loader"
]
},{
test: /\.tsx?$/i,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
}]
}
}