2022-02-27 14:59:17 -07:00
|
|
|
import { dirname, resolve } from 'path'
|
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
|
|
|
import MiniCssExtractPlugin from "mini-css-extract-plugin"
|
2022-02-25 11:18:46 -07:00
|
|
|
|
2022-02-27 14:59:17 -07:00
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
|
|
|
export default (env) => {
|
2022-02-25 11:18:46 -07:00
|
|
|
let config
|
|
|
|
if (env.static) {
|
|
|
|
config = {
|
|
|
|
mode: env.mode,
|
|
|
|
entry: {
|
|
|
|
main: {
|
|
|
|
import: './static-src/index.js',
|
|
|
|
dependOn: 'openpgp',
|
|
|
|
},
|
|
|
|
openpgp: './node_modules/openpgp/dist/openpgp.js',
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
2022-02-27 14:59:17 -07:00
|
|
|
path: resolve(__dirname, 'static'),
|
2022-02-25 11:18:46 -07:00
|
|
|
},
|
|
|
|
watch: env.mode == "development",
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
'css-loader'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2022-02-27 14:59:17 -07:00
|
|
|
resolve: {
|
|
|
|
fallback: {
|
|
|
|
crypto: false,
|
|
|
|
}
|
|
|
|
},
|
2022-02-25 11:18:46 -07:00
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
],
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env.mode == 'development') {
|
|
|
|
config.plugins.push(new BundleAnalyzerPlugin({
|
|
|
|
openAnalyzer: false
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|