-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
63 lines (58 loc) · 1.78 KB
/
webpack.prod.js
File metadata and controls
63 lines (58 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const fs = require('fs/promises');
const packageInfo = require('./package.json');
const dateFns = require('date-fns');
const { merge } = require('webpack-merge');
const webpack = require('webpack');
const { webpackCommonConfig } = require('./webpack.common.js');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
class CreateFilePlugin {
constructor() {}
apply(compiler) {
compiler.hooks.afterEmit.tap(this.constructor.name, async (compilation) => {
const buildPath = compilation.options.output.path;
const version = packageInfo.version;
const buildDate = dateFns.format(new Date(), 'yymmdd-hhmmss');
const text = `version: ${version} ${buildDate}`;
fs.writeFile(`${buildPath}/version.txt`, text, 'utf8').catch((err) => {
console.error(err);
});
});
}
}
const isLocalBuild = process.env.LOCAL_BUILD === 'true';
module.exports = merge(webpackCommonConfig, {
entry: './src/app/web/index.tsx',
mode: 'production',
output: {
path: path.resolve('dist/'),
filename: 'app.[chunkhash].js',
// prefix 개념 번들 파일 앞에 요청할 주소 ec2 url 이나 s3
publicPath: isLocalBuild ? './' : '/graphpainter/',
clean: true,
},
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
plugins: [
new ESLintPlugin({
extensions: ['ts', 'tsx'],
failOnError: true,
}),
new webpack.DefinePlugin({
'process.env.APP_VERSION': JSON.stringify(packageInfo.version),
'process.env.BUILD_TARGET': JSON.stringify('web'),
}),
new CreateFilePlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: './public',
},
],
}),
],
});