const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
mode: 'production',
entry: {
'main': './src/main/main.js',
'page2': './src/main/second.js'
},
output: {
path: path.resolve(__dirname, 'public'),
publicPath: '/public/',
filename: './[name].js',
},
optimization: {
usedExports: true,
minimize: true,
minimizer: [new TerserPlugin()],
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
chunks: ['main'],
filename: "index.html",
template: 'index.html',
}),
new HtmlWebpackPlugin({
inject: false,
chunks: ['page2'],
filename: 'pages/second.html',
template: 'pages/second.html',
}),
new CleanWebpackPlugin(),
],
module: {
rules: [
{
test: /\.(jpg|png|jpe?g|gif)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
// publicPath: 'file:///android_asset/Game/',
},
},
{
type: 'javascript/auto',
test: /\.(json)/,
exclude: /(node_modules|bower_components)/,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
// publicPath: 'file:///android_asset/Game/',
},
},
],
},
performance: {
maxEntrypointSize: 1024000,
maxAssetSize: 1024000
},
devServer: {
publicPath: '/public/',
inline:true,
stats:"errors-only",
compress: true,
port: 9000,
hot: true,
open: true,
},
}
json
"scripts": {
"build": "webpack --config webpack.config.js",
"start": "webpack-dev-server --mode development",
"format": "prettier --write '**/*.js'"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"three": "^0.115.0"
},
"devDependencies": {
"clean-webpack-plugin": "^4.0.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^4.5.2",
"prettier": "^2.0.4",
"terser-webpack-plugin": "^4.2.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
}