Migrated from parcel to webpack
The whole idea of parcel was that it was configless. Now parcel 2 needs a config file. At that point, why not use webpack?
This commit is contained in:
84
webpack.config.js
Normal file
84
webpack.config.js
Normal file
@@ -0,0 +1,84 @@
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return ({
|
||||
stats: 'minimal', // Keep console output easy to read.
|
||||
entry: './src/index.ts', // Your program entry point
|
||||
|
||||
// Your build destination
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'bundle.js'
|
||||
},
|
||||
|
||||
// Config for your testing server
|
||||
devServer: {
|
||||
compress: true,
|
||||
static: false,
|
||||
client: {
|
||||
logging: "warn",
|
||||
overlay: {
|
||||
errors: true,
|
||||
warnings: false,
|
||||
},
|
||||
progress: true,
|
||||
},
|
||||
port: 1234, host: '0.0.0.0'
|
||||
},
|
||||
|
||||
// Web games are bigger than pages, disable the warnings that our game is too big.
|
||||
performance: { hints: false },
|
||||
|
||||
// Enable sourcemaps while debugging
|
||||
devtool: argv.mode === 'development' ? 'eval-source-map' : undefined,
|
||||
|
||||
// Minify the code when making a final build
|
||||
optimization: {
|
||||
minimize: argv.mode === 'production',
|
||||
minimizer: [new TerserPlugin({
|
||||
terserOptions: {
|
||||
ecma: 6,
|
||||
compress: { drop_console: true },
|
||||
output: { comments: false, beautify: false },
|
||||
},
|
||||
})],
|
||||
},
|
||||
|
||||
|
||||
// Explain webpack how to do Typescript
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x)?$/,
|
||||
loader: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
'.tsx',
|
||||
'.ts',
|
||||
'.js'
|
||||
]
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// Copy our static assets to the final build
|
||||
new CopyPlugin({
|
||||
patterns: [{ from: 'static/' }],
|
||||
}),
|
||||
|
||||
// Make an index.html from the template
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'src/index.ejs',
|
||||
hash: true,
|
||||
minify: false
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user