chore: update 9 file(s)
This commit is contained in:
92
webpack.config.js
Normal file
92
webpack.config.js
Normal file
@@ -0,0 +1,92 @@
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
||||
import CopyWebpackPlugin from 'copy-webpack-plugin'
|
||||
import { CleanWebpackPlugin } from 'clean-webpack-plugin'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
export default (env, argv) => {
|
||||
const isProduction = argv.mode === 'production'
|
||||
|
||||
return {
|
||||
mode: isProduction ? 'production' : 'development',
|
||||
|
||||
entry: {
|
||||
wwww: './www/chatv3.js'
|
||||
},
|
||||
|
||||
output: {
|
||||
path : path.resolve(__dirname, 'dist'),
|
||||
filename : isProduction ? 'js/[name].[contenthash:8].js' : 'js/[name].js',
|
||||
publicPath: isProduction ? '../' : '/'
|
||||
},
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use : [
|
||||
MiniCssExtractPlugin.loader,
|
||||
'css-loader'
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(),
|
||||
|
||||
new MiniCssExtractPlugin({
|
||||
filename: isProduction ? 'css/[name].[contenthash:8].css' : 'css/[name].css'
|
||||
}),
|
||||
|
||||
new HtmlWebpackPlugin({
|
||||
template: './www/index.html',
|
||||
filename: 'index.html',
|
||||
chunks : ['wwww'],
|
||||
inject : 'body',
|
||||
minify : isProduction
|
||||
}),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{ from: 'www/404.html', to: '404.html' },
|
||||
{ from: 'www/favicon.ico', to: 'favicon.ico' },
|
||||
{ from: 'www/icon.svg', to: 'icon.svg' },
|
||||
{ from: 'robots.txt', to: 'robots.txt', noErrorOnMissing: true },
|
||||
{ from: 'site.webmanifest', to: 'site.webmanifest', noErrorOnMissing: true }
|
||||
]
|
||||
})
|
||||
],
|
||||
|
||||
optimization: {
|
||||
moduleIds : 'deterministic',
|
||||
runtimeChunk: 'single',
|
||||
splitChunks : {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
test : /[\\/]node_modules[\\/]/,
|
||||
name : 'vendors',
|
||||
chunks: 'all'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
devtool: isProduction ? 'source-map' : 'eval-source-map',
|
||||
|
||||
devServer: {
|
||||
host : '0.0.0.0',
|
||||
port : 8082,
|
||||
allowedHosts : 'all',
|
||||
hot : true,
|
||||
devMiddleware: { publicPath: '/' },
|
||||
static : [
|
||||
{ directory: path.resolve(__dirname, 'dist') },
|
||||
{ directory: path.resolve(__dirname, 'www'), publicPath: '/' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user