Showing
2 changed files
with
24 additions
and
22 deletions
@@ -5,14 +5,21 @@ | @@ -5,14 +5,21 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | + | ||
9 | +const os = require('os'); | ||
8 | const path = require('path'); | 10 | const path = require('path'); |
9 | const shelljs = require('shelljs'); | 11 | const shelljs = require('shelljs'); |
10 | const _ = require('lodash'); | 12 | const _ = require('lodash'); |
11 | const webpack = require('webpack'); | 13 | const webpack = require('webpack'); |
14 | +const HappyPack = require('happypack'); | ||
12 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); | 15 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
13 | const scss = require('postcss-scss'); | 16 | const scss = require('postcss-scss'); |
14 | const postcssConfig = require('./postcss.config.js'); | 17 | const postcssConfig = require('./postcss.config.js'); |
15 | 18 | ||
19 | +const happyThreadPool = HappyPack.ThreadPool({ // eslint-disable-line | ||
20 | + size: os.cpus().length | ||
21 | +}); | ||
22 | + | ||
16 | const hbsLoader = { | 23 | const hbsLoader = { |
17 | loader: 'handlebars-loader', | 24 | loader: 'handlebars-loader', |
18 | options: { | 25 | options: { |
@@ -125,13 +132,23 @@ module.exports = (env) => { | @@ -125,13 +132,23 @@ module.exports = (env) => { | ||
125 | path.join(__dirname, '../js') | 132 | path.join(__dirname, '../js') |
126 | ], | 133 | ], |
127 | alias: { | 134 | alias: { |
128 | - vue: 'vue/dist/vue.js' | 135 | + vue: 'vue/dist/vue.common.js' |
129 | } | 136 | } |
130 | }, | 137 | }, |
131 | stats: { | 138 | stats: { |
132 | children: false | 139 | children: false |
133 | }, | 140 | }, |
134 | plugins: [ | 141 | plugins: [ |
142 | + new HappyPack({ | ||
143 | + id: 'js', | ||
144 | + threadPool: happyThreadPool, | ||
145 | + loaders: ['babel-loader'], | ||
146 | + }), | ||
147 | + new HappyPack({ | ||
148 | + id: 'hbs', | ||
149 | + threadPool: happyThreadPool, | ||
150 | + loaders: [hbsLoader] | ||
151 | + }), | ||
135 | new webpack.optimize.CommonsChunkPlugin({ | 152 | new webpack.optimize.CommonsChunkPlugin({ |
136 | name: 'libs', | 153 | name: 'libs', |
137 | filename: 'libs.js' | 154 | filename: 'libs.js' |
@@ -141,9 +158,6 @@ module.exports = (env) => { | @@ -141,9 +158,6 @@ module.exports = (env) => { | ||
141 | jQuery: 'yoho-jquery', | 158 | jQuery: 'yoho-jquery', |
142 | 'window.jQuery': 'yoho-jquery' | 159 | 'window.jQuery': 'yoho-jquery' |
143 | }) | 160 | }) |
144 | - ], | ||
145 | - extends: { | ||
146 | - hbsLoader | ||
147 | - } | 161 | + ] |
148 | }; | 162 | }; |
149 | }; | 163 | }; |
@@ -5,17 +5,12 @@ const path = require('path'); | @@ -5,17 +5,12 @@ const path = require('path'); | ||
5 | const shelljs = require('shelljs'); | 5 | const shelljs = require('shelljs'); |
6 | const _ = require('lodash'); | 6 | const _ = require('lodash'); |
7 | const webpack = require('webpack'); | 7 | const webpack = require('webpack'); |
8 | -const HappyPack = require('happypack'); | ||
9 | const UglifyJsParallelPlugin = require('webpack-uglify-parallel'); | 8 | const UglifyJsParallelPlugin = require('webpack-uglify-parallel'); |
10 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); | 9 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
11 | const config = require('../../package.json'); | 10 | const config = require('../../package.json'); |
12 | const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`); | 11 | const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`); |
13 | let baseConfig = require('./webpack.base.config.js'); | 12 | let baseConfig = require('./webpack.base.config.js'); |
14 | 13 | ||
15 | -const happyThreadPool = HappyPack.ThreadPool({ // eslint-disable-line | ||
16 | - size: os.cpus().length | ||
17 | -}); | ||
18 | - | ||
19 | // cope img font | 14 | // cope img font |
20 | shelljs.mkdir('-p', distDir); | 15 | shelljs.mkdir('-p', distDir); |
21 | shelljs.cp('-R', path.join(__dirname, '../img/'), distDir); | 16 | shelljs.cp('-R', path.join(__dirname, '../img/'), distDir); |
@@ -29,21 +24,16 @@ _.mergeWith(baseConfig, { | @@ -29,21 +24,16 @@ _.mergeWith(baseConfig, { | ||
29 | }, | 24 | }, |
30 | plugins: [ | 25 | plugins: [ |
31 | new ExtractTextPlugin('[name].css'), | 26 | new ExtractTextPlugin('[name].css'), |
32 | - new HappyPack({ | ||
33 | - id: 'js', | ||
34 | - threadPool: happyThreadPool, | ||
35 | - loaders: ['babel-loader'], | ||
36 | - }), | ||
37 | - new HappyPack({ | ||
38 | - id: 'hbs', | ||
39 | - threadPool: happyThreadPool, | ||
40 | - loaders: [baseConfig.extends.hbsLoader] | ||
41 | - }), | ||
42 | new webpack.DefinePlugin({ | 27 | new webpack.DefinePlugin({ |
43 | 'process.env': { | 28 | 'process.env': { |
44 | NODE_ENV: '"production"' | 29 | NODE_ENV: '"production"' |
45 | } | 30 | } |
46 | }), | 31 | }), |
32 | + new webpack.optimize.UglifyJsPlugin({ | ||
33 | + compress: { | ||
34 | + warnings: false | ||
35 | + } | ||
36 | + }), | ||
47 | new UglifyJsParallelPlugin({ | 37 | new UglifyJsParallelPlugin({ |
48 | workers: os.cpus().length, | 38 | workers: os.cpus().length, |
49 | compress: { | 39 | compress: { |
@@ -58,6 +48,4 @@ _.mergeWith(baseConfig, { | @@ -58,6 +48,4 @@ _.mergeWith(baseConfig, { | ||
58 | } | 48 | } |
59 | }); | 49 | }); |
60 | 50 | ||
61 | -delete baseConfig.extends; | ||
62 | - | ||
63 | module.exports = baseConfig; | 51 | module.exports = baseConfig; |
-
Please register or login to post a comment