Skip to content

Commit 152f787

Browse files
committed
simplify build process and add support for tree shaking
1 parent ee17f32 commit 152f787

File tree

10 files changed

+529
-398
lines changed

10 files changed

+529
-398
lines changed

.babelrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
{
22
"presets": [
3-
"es2015",
4-
"es2017",
5-
"stage-0",
63
[
74
"env",
85
{
6+
"modules": false,
97
"targets": {
108
"browsers": ["last 3 versions", "not IE < 10"]
119
}
1210
}
1311
]
1412
],
1513
"plugins": [
16-
"transform-runtime",
17-
"add-module-exports"
14+
"add-module-exports",
15+
"transform-object-rest-spread"
1816
]
1917
}

build/server/build-docs.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1+
import ora from 'ora';
2+
import chalk from 'chalk';
13
import webpack from 'webpack';
2-
import build from './build';
34
import webpackConfig from '../webpack/prod-docs';
45

5-
webpack(webpackConfig, build);
6+
const spinner = ora(chalk.cyan('Building website'));
7+
8+
process.stdout.write('\n');
9+
spinner.start();
10+
11+
webpack(webpackConfig, (error, stats) => {
12+
if (error) {
13+
spinner.fail(chalk.red('Something wrong happened:\n'));
14+
15+
throw error;
16+
}
17+
18+
process.stdout.write('\n\n' + stats.toString({
19+
colors: true,
20+
modules: false,
21+
children: false,
22+
chunks: false,
23+
chunkModules: false
24+
}) + '\n\n');
25+
26+
spinner.succeed(chalk.green('Documentation builded with success!\n'));
27+
});

build/server/build-lib.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1+
import ora from 'ora';
2+
import chalk from 'chalk';
13
import webpack from 'webpack';
2-
import build from './build';
34
import webpackConfig from '../webpack/prod-lib';
45
import webpackDebugConfig from '../webpack/debug-lib';
56

6-
webpack([webpackConfig, webpackDebugConfig], build);
7+
const spinner = ora(chalk.cyan('Building library'));
8+
9+
process.stdout.write('\n');
10+
spinner.start();
11+
12+
webpack([webpackConfig, webpackDebugConfig], (error, stats) => {
13+
if (error) {
14+
spinner.fail(chalk.red('Something wrong happened:\n'));
15+
16+
throw error;
17+
}
18+
19+
process.stdout.write('\n\n' + stats.toString({
20+
colors: true,
21+
modules: false,
22+
children: false,
23+
chunks: false,
24+
chunkModules: false
25+
}) + '\n\n');
26+
27+
spinner.succeed(chalk.green('Build finished with success!\n'));
28+
});

build/server/build.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

build/server/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import historyApiFallback from 'connect-history-api-fallback';
88
import config from '../config';
99
import webpackConfig from '../webpack/dev';
1010

11-
1211
const app = express();
1312
const compiler = webpack(webpackConfig);
1413
const rootPath = path.join(__dirname, '..', '..');

build/webpack/dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object.keys(baseWebpackConfig.entry).forEach((name) => {
1010
});
1111

1212
export default merge(baseWebpackConfig, {
13-
devtool: 'cheap-module-eval-source-map',
13+
devtool: '#cheap-module-eval-source-map',
1414
module: {
1515
rules: [
1616
{

build/webpack/prod-docs.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,16 @@ const conf = merge(baseConfig, {
6767
}),
6868
new webpack.optimize.UglifyJsPlugin({
6969
compress: {
70-
warnings: false
70+
warnings: false,
71+
screw_ie8: true,
72+
conditionals: true,
73+
unused: true,
74+
comparisons: true,
75+
sequences: true,
76+
dead_code: true,
77+
evaluate: true,
78+
join_vars: true,
79+
if_return: true
7180
},
7281
output: {
7382
comments: false
@@ -134,7 +143,9 @@ const conf = merge(baseConfig, {
134143
name: 'manifest',
135144
chunks: ['vendor']
136145
}),
137-
new OptimizeCssAssetsPlugin()
146+
new OptimizeCssAssetsPlugin({
147+
canPrint: false
148+
})
138149
]
139150
});
140151

build/webpack/prod-lib.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,16 @@ export default merge(baseConfig, {
9393
}),
9494
new webpack.optimize.UglifyJsPlugin({
9595
compress: {
96-
warnings: false
96+
warnings: false,
97+
screw_ie8: true,
98+
conditionals: true,
99+
unused: true,
100+
comparisons: true,
101+
sequences: true,
102+
dead_code: true,
103+
evaluate: true,
104+
join_vars: true,
105+
if_return: true
97106
},
98107
output: {
99108
comments: false
@@ -113,6 +122,8 @@ export default merge(baseConfig, {
113122
entryOnly: true
114123
}),
115124
new ExtractTextPlugin('[name].css'),
116-
new OptimizeCssAssetsPlugin()
125+
new OptimizeCssAssetsPlugin({
126+
canPrint: false
127+
})
117128
]
118129
});

package.json

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,53 +43,52 @@
4343
"vue": "^2.1.10"
4444
},
4545
"devDependencies": {
46-
"autoprefixer": "^6.7.2",
46+
"autoprefixer": "^6.7.4",
4747
"autosize": "^3.0.20",
48-
"babel-cli": "^6.22.2",
49-
"babel-core": "^6.22.1",
48+
"babel-cli": "^6.23.0",
49+
"babel-core": "^6.23.1",
5050
"babel-eslint": "^7.1.1",
51-
"babel-loader": "^6.2.10",
51+
"babel-loader": "^6.3.2",
5252
"babel-plugin-add-module-exports": "^0.2.1",
53-
"babel-plugin-transform-runtime": "^6.22.0",
53+
"babel-plugin-transform-object-rest-spread": "^6.23.0",
5454
"babel-preset-env": "^1.1.8",
5555
"babel-preset-es2015": "^6.22.0",
56-
"babel-preset-es2017": "^6.22.0",
5756
"babel-preset-stage-0": "^6.22.0",
5857
"chalk": "^1.1.3",
5958
"chokidar": "^1.6.1",
60-
"clipboard": "^1.5.16",
59+
"clipboard": "^1.6.0",
6160
"connect-history-api-fallback": "^1.3.0",
6261
"copy-webpack-plugin": "^4.0.1",
6362
"css-loader": "^0.26.1",
6463
"css-mqpacker": "^5.0.1",
64+
"date-fns": "^1.27.2",
6565
"element.scrollintoviewifneeded-polyfill": "^1.0.1",
66-
"eslint": "^3.15.0",
66+
"eslint": "^3.16.0",
6767
"eslint-friendly-formatter": "^2.0.7",
6868
"eslint-loader": "^1.6.1",
69-
"eslint-plugin-html": "^2.0.0",
69+
"eslint-plugin-html": "^2.0.1",
7070
"eventsource-polyfill": "^0.9.6",
7171
"express": "^4.14.1",
7272
"extract-text-webpack-plugin": "beta",
73-
"file-loader": "^0.10.0",
74-
"friendly-errors-webpack-plugin": "^1.1.3",
73+
"friendly-errors-webpack-plugin": "^1.3.1",
7574
"highlight.js": "^9.9.0",
7675
"html-webpack-plugin": "^2.28.0",
7776
"node-sass": "^4.5.0",
7877
"optimize-css-assets-webpack-plugin": "^1.3.0",
7978
"optimize-js-plugin": "^0.0.4",
8079
"ora": "^1.1.0",
8180
"raw-loader": "^0.5.1",
82-
"sass-loader": "^5.0.0",
81+
"sass-loader": "^6.0.2",
8382
"url-loader": "^0.5.7",
84-
"vue-hot-reload-api": "^2.0.8",
83+
"vue-hot-reload-api": "^2.0.9",
8584
"vue-html-loader": "^1.2.3",
86-
"vue-loader": "^10.3.0",
87-
"vue-router": "^2.2.0",
85+
"vue-loader": "^11.1.0",
86+
"vue-router": "^2.2.1",
8887
"vue-style-loader": "^2.0.0",
8988
"vue-template-compiler": "^2.1.10",
9089
"webpack": "^2.2.1",
91-
"webpack-dev-middleware": "^1.10.0",
92-
"webpack-hot-middleware": "^2.16.1",
93-
"webpack-merge": "^2.6.1"
90+
"webpack-dev-middleware": "^1.10.1",
91+
"webpack-hot-middleware": "^2.17.0",
92+
"webpack-merge": "^3.0.0"
9493
}
9594
}

0 commit comments

Comments
 (0)