-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
executable file
·56 lines (52 loc) · 1.39 KB
/
Copy pathwebpack.prod.js
File metadata and controls
executable file
·56 lines (52 loc) · 1.39 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
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/seamless-scroll.js'),
output: {
path: path.resolve(__dirname, 'lib'),
filename: 'seamless-scroll.min.js',
library: 'SeamlessScroll',
libraryTarget: 'umd',
libraryExport: 'default'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
}
};
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('大功告成!👏 👏 👏\n'));
console.log(
chalk.yellow(
'Tip: 提交 PR 之前不要忘记修改 package.json 里的版本号哦!方便我 Review 后麻溜溜的发布到 npm。\n'
)
);
});
});