Authored by ccbikai(👎🏻🍜)

happy

... ... @@ -5,14 +5,21 @@
*/
'use strict';
const os = require('os');
const path = require('path');
const shelljs = require('shelljs');
const _ = require('lodash');
const webpack = require('webpack');
const HappyPack = require('happypack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const scss = require('postcss-scss');
const postcssConfig = require('./postcss.config.js');
const happyThreadPool = HappyPack.ThreadPool({ // eslint-disable-line
size: os.cpus().length
});
const hbsLoader = {
loader: 'handlebars-loader',
options: {
... ... @@ -125,13 +132,23 @@ module.exports = (env) => {
path.join(__dirname, '../js')
],
alias: {
vue: 'vue/dist/vue.js'
vue: 'vue/dist/vue.common.js'
}
},
stats: {
children: false
},
plugins: [
new HappyPack({
id: 'js',
threadPool: happyThreadPool,
loaders: ['babel-loader'],
}),
new HappyPack({
id: 'hbs',
threadPool: happyThreadPool,
loaders: [hbsLoader]
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'libs',
filename: 'libs.js'
... ... @@ -141,9 +158,6 @@ module.exports = (env) => {
jQuery: 'yoho-jquery',
'window.jQuery': 'yoho-jquery'
})
],
extends: {
hbsLoader
}
]
};
};
... ...
... ... @@ -5,17 +5,12 @@ const path = require('path');
const shelljs = require('shelljs');
const _ = require('lodash');
const webpack = require('webpack');
const HappyPack = require('happypack');
const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = require('../../package.json');
const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`);
let baseConfig = require('./webpack.base.config.js');
const happyThreadPool = HappyPack.ThreadPool({ // eslint-disable-line
size: os.cpus().length
});
// cope img font
shelljs.mkdir('-p', distDir);
shelljs.cp('-R', path.join(__dirname, '../img/'), distDir);
... ... @@ -29,21 +24,16 @@ _.mergeWith(baseConfig, {
},
plugins: [
new ExtractTextPlugin('[name].css'),
new HappyPack({
id: 'js',
threadPool: happyThreadPool,
loaders: ['babel-loader'],
}),
new HappyPack({
id: 'hbs',
threadPool: happyThreadPool,
loaders: [baseConfig.extends.hbsLoader]
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new UglifyJsParallelPlugin({
workers: os.cpus().length,
compress: {
... ... @@ -58,6 +48,4 @@ _.mergeWith(baseConfig, {
}
});
delete baseConfig.extends;
module.exports = baseConfig;
... ...