-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
55 lines (51 loc) · 1.21 KB
/
webpack.prod.js
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
const path = require('path');
const ora = require('ora');
const chalk = require('chalk');
const rm = require('rimraf');
const webpack = require('webpack');
const webpackConfig = {
mode: 'production',
entry: path.resolve(__dirname, 'src/s-carousel.ts'),
output: {
path: path.resolve(__dirname, 'lib'),
filename: 's-carousel.js',
library: 'SCarousel',
libraryTarget: 'umd',
libraryExport: 'default',
clean: true,
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"]
},
module: {
rules: [
{
test: /\.ts?$/,
use: 'ts-loader',
exclude: /node_modules/,
}
]
},
};
const spinner = ora('building for production...');
spinner.start();
rm(path.resolve(__dirname, 'lib'), err => {
if (err) throw err;
webpack(webpackConfig, (err, stats) => {
spinner.stop();
if (err) throw err;
process.stdout.write(
stats.toString({
colors: true,
modules: false,
chunks: false,
chunkModules: false
}) + '\n\n'
);
if (stats.hasErrors()) {
console.log(chalk.red('Build failed with errors.\n'));
process.exit(1);
}
console.log(chalk.cyan('Congratulate! Build succeeded!\n'));
});
});