Merge pull request #1441 from vparomskiy/master
cache webpack resources and run loaders in concurrent mode
This commit is contained in:
commit
d78202018a
@ -11,7 +11,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "babel-node --max_old_space_size=4096 server.js",
|
"start": "babel-node --max_old_space_size=4096 server.js",
|
||||||
"build": "cross-env NODE_ENV=production webpack -p"
|
"build": "cross-env NODE_ENV=production webpack"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@flowjs/ng-flow": "^2.7.1",
|
"@flowjs/ng-flow": "^2.7.1",
|
||||||
@ -136,7 +136,9 @@
|
|||||||
"webpack-dev-middleware": "^1.6.1",
|
"webpack-dev-middleware": "^1.6.1",
|
||||||
"webpack-dev-server": "^1.15.1",
|
"webpack-dev-server": "^1.15.1",
|
||||||
"webpack-hot-middleware": "^2.12.2",
|
"webpack-hot-middleware": "^2.12.2",
|
||||||
"webpack-material-design-icons": "^0.1.0"
|
"webpack-material-design-icons": "^0.1.0",
|
||||||
|
"uglifyjs-webpack-plugin": "^1.3.0",
|
||||||
|
"happypack": "^5.0.1"
|
||||||
},
|
},
|
||||||
"engine": "node >= 5.9.0",
|
"engine": "node >= 5.9.0",
|
||||||
"nyc": {
|
"nyc": {
|
||||||
|
|||||||
@ -18,13 +18,16 @@
|
|||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
const StyleLintPlugin = require('stylelint-webpack-plugin')
|
const StyleLintPlugin = require('stylelint-webpack-plugin');
|
||||||
|
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const dirTree = require('directory-tree');
|
const dirTree = require('directory-tree');
|
||||||
const jsonminify = require("jsonminify");
|
const jsonminify = require("jsonminify");
|
||||||
|
|
||||||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||||
|
const HappyPack = require('happypack');
|
||||||
|
|
||||||
const PUBLIC_RESOURCE_PATH = '/';
|
const PUBLIC_RESOURCE_PATH = '/';
|
||||||
|
|
||||||
var langs = [];
|
var langs = [];
|
||||||
@ -34,6 +37,9 @@ dirTree('./src/app/locale/', {extensions:/\.json$/}, (item) => {
|
|||||||
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5));
|
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var happyThreadPool = HappyPack.ThreadPool({ size: 3 });
|
||||||
|
|
||||||
/* devtool: 'cheap-module-eval-source-map', */
|
/* devtool: 'cheap-module-eval-source-map', */
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -93,6 +99,25 @@ module.exports = {
|
|||||||
PUBLIC_PATH: JSON.stringify(PUBLIC_RESOURCE_PATH),
|
PUBLIC_PATH: JSON.stringify(PUBLIC_RESOURCE_PATH),
|
||||||
SUPPORTED_LANGS: JSON.stringify(langs)
|
SUPPORTED_LANGS: JSON.stringify(langs)
|
||||||
}),
|
}),
|
||||||
|
new UglifyJsPlugin({
|
||||||
|
cache: true,
|
||||||
|
parallel: true
|
||||||
|
}),
|
||||||
|
new HappyPack({
|
||||||
|
threadPool: happyThreadPool,
|
||||||
|
id: 'cached-babel',
|
||||||
|
loaders: ["babel-loader?cacheDirectory=true"]
|
||||||
|
}),
|
||||||
|
new HappyPack({
|
||||||
|
threadPool: happyThreadPool,
|
||||||
|
id: 'eslint',
|
||||||
|
loaders: ["eslint-loader?{parser: 'babel-eslint'}"]
|
||||||
|
}),
|
||||||
|
new HappyPack({
|
||||||
|
threadPool: happyThreadPool,
|
||||||
|
id: 'ng-annotate-and-cached-babel-loader',
|
||||||
|
loaders: ['ng-annotate', 'babel-loader?cacheDirectory=true']
|
||||||
|
})
|
||||||
],
|
],
|
||||||
node: {
|
node: {
|
||||||
tls: "empty",
|
tls: "empty",
|
||||||
@ -102,19 +127,19 @@ module.exports = {
|
|||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
test: /\.jsx$/,
|
test: /\.jsx$/,
|
||||||
loader: 'babel',
|
loader: 'happypack/loader?id=cached-babel',
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: __dirname,
|
include: __dirname,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loaders: ['ng-annotate', 'babel'],
|
loaders: ['happypack/loader?id=ng-annotate-and-cached-babel-loader'],
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: __dirname,
|
include: __dirname,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loader: "eslint-loader?{parser: 'babel-eslint'}",
|
loader: 'happypack/loader?id=eslint',
|
||||||
exclude: /node_modules|vendor/,
|
exclude: /node_modules|vendor/,
|
||||||
include: __dirname,
|
include: __dirname,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -23,6 +23,8 @@ const webpack = require('webpack');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const dirTree = require('directory-tree');
|
const dirTree = require('directory-tree');
|
||||||
const jsonminify = require("jsonminify");
|
const jsonminify = require("jsonminify");
|
||||||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||||
|
const HappyPack = require('happypack');
|
||||||
|
|
||||||
const PUBLIC_RESOURCE_PATH = '/static/';
|
const PUBLIC_RESOURCE_PATH = '/static/';
|
||||||
|
|
||||||
@ -33,6 +35,8 @@ dirTree('./src/app/locale/', {extensions:/\.json$/}, (item) => {
|
|||||||
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5));
|
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var happyThreadPool = HappyPack.ThreadPool({ size: 3 });
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
entry: [
|
entry: [
|
||||||
@ -95,6 +99,25 @@ module.exports = {
|
|||||||
test: /\.js$|\.css$|\.svg$|\.ttf$|\.woff$|\.woff2|\.eot$\.json$/,
|
test: /\.js$|\.css$|\.svg$|\.ttf$|\.woff$|\.woff2|\.eot$\.json$/,
|
||||||
threshold: 10240,
|
threshold: 10240,
|
||||||
minRatio: 0.8
|
minRatio: 0.8
|
||||||
|
}),
|
||||||
|
new UglifyJsPlugin({
|
||||||
|
cache: true,
|
||||||
|
parallel: true
|
||||||
|
}),
|
||||||
|
new HappyPack({
|
||||||
|
threadPool: happyThreadPool,
|
||||||
|
id: 'cached-babel',
|
||||||
|
loaders: ["babel-loader?cacheDirectory=true"]
|
||||||
|
}),
|
||||||
|
new HappyPack({
|
||||||
|
threadPool: happyThreadPool,
|
||||||
|
id: 'eslint',
|
||||||
|
loaders: ["eslint-loader?{parser: 'babel-eslint'}"]
|
||||||
|
}),
|
||||||
|
new HappyPack({
|
||||||
|
threadPool: happyThreadPool,
|
||||||
|
id: 'ng-annotate-and-cached-babel-loader',
|
||||||
|
loaders: ['ng-annotate', 'babel-loader?cacheDirectory=true']
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
node: {
|
node: {
|
||||||
@ -105,19 +128,20 @@ module.exports = {
|
|||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
test: /\.jsx$/,
|
test: /\.jsx$/,
|
||||||
loader: 'babel',
|
loader: 'happypack/loader?id=cached-babel',
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: __dirname,
|
include: __dirname,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loaders: ['ng-annotate', 'babel'],
|
loaders: ['happypack/loader?id=ng-annotate-and-cached-babel-loader'],
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: __dirname,
|
include: __dirname,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loader: "eslint-loader?{parser: 'babel-eslint'}",
|
loaders: ['happypack/loader?id=eslint'],
|
||||||
|
// loader: "eslint-loader?{parser: 'babel-eslint'}",
|
||||||
exclude: /node_modules|vendor/,
|
exclude: /node_modules|vendor/,
|
||||||
include: __dirname,
|
include: __dirname,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user