Authored by yyq

update

... ... @@ -74,10 +74,10 @@
"eslint": "^3.16.0",
"eslint-config-yoho": "^1.0.9",
"eslint-loader": "^1.6.3",
"extract-text-webpack-plugin": "^2.1.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"handlebars": "4.0.5",
"handlebars-loader": "^1.4.0",
"happypack": "^3.0.3",
"happypack": "^5.0.0-beta.3",
"husky": "^0.11.4",
"jquery-ui": "^1.12.1",
"nodemon": "1.9.2",
... ... @@ -88,7 +88,7 @@
"postcss-clearfix": "^1.0.0",
"postcss-crip": "^2.0.1",
"postcss-import": "^9.1.0",
"postcss-loader": "^1.3.1",
"postcss-loader": "^2.1.4",
"postcss-opacity": "^4.0.0",
"postcss-position": "^0.5.0",
"postcss-pxtorem": "^4.0.0",
... ... @@ -104,13 +104,13 @@
"stylelint": "^8.4.0",
"stylelint-config-yoho": "^1.2.11",
"stylelint-formatter-table": "^1.0.3",
"stylelint-webpack-plugin": "^0.7.0",
"webpack": "^2.3.1",
"webpack-dev-server": "^2.4.2",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15",
"webpack-dev-server": "^3.1.3",
"yoho-eventproxy": "^0.3.6",
"yoho-handlebars": "^4.0.5",
"yoho-handlebars": "^4.0.6",
"yoho-jquery": "^1.12.4",
"yoho-jquery-dotdotdot": "0.0.1",
"yoho-jquery-dotdotdot": "0.0.2",
"yoho-jquery-lazyload": "1.9.7",
"yoho-jquery-pjax": "0.0.1",
"yoho-jquery-placeholder": "^2.3.1",
... ...
... ... @@ -59,16 +59,6 @@ const cssLoader = (env, type) => {
const getEntries = () => {
const entries = {
libs: [
'yoho-handlebars',
'yoho-jquery',
'yoho-jquery-lazyload',
'yoho-slider',
'yoho-jquery-pjax',
'yoho-jquery-dotdotdot',
'regenerator-runtime/runtime',
path.join(__dirname, '../js/global.js')
],
base: path.join(__dirname, '../scss/base.css')
};
... ... @@ -88,13 +78,24 @@ const getEntries = () => {
// Important
// 生成规则:module.page: './js/module/xx.page.js'
entries[`${dir[0]}.${dir[1].match(/(.*).page.js/)[1]}`] = path.join(__dirname, `../js/${dir.join('/')}`);
entries[`${dir[0]}.${dir[1].match(/(.*).page.js/)[1]}`] = [path.join(__dirname, '../js/global.js'),
path.join(__dirname, `../js/${dir.join('/')}`)];
});
return entries;
};
module.exports = (env) => {
const libs = [
'yoho-handlebars',
'yoho-jquery',
'yoho-jquery-lazyload',
'yoho-slider',
'yoho-jquery-pjax',
'yoho-jquery-dotdotdot',
path.join(__dirname, '../js/global.js')
];
return {
entry: getEntries(),
output: {
... ... @@ -104,21 +105,6 @@ module.exports = (env) => {
devtool: 'hidden-source-map',
module: {
rules: [{
test: /\.vue$/,
use: [{
loader: 'vue-loader',
options: {
postcss: {
plugins: postcssConfig.postcssPlugin(env),
parser: scss
},
autoprefixer: false,
loaders: {
css: cssLoader(env, 'vue')
}
}
}]
}, {
test: /\.js$/,
exclude: [/node_modules/],
use: [{
... ... @@ -151,6 +137,29 @@ module.exports = (env) => {
stats: {
children: false
},
optimization: {
splitChunks: {
cacheGroups: {
default: false,
libs: {
test: (file) => {
if (libs.indexOf(file.rawRequest) >= 0) {
return true;
}
return false;
},
name: 'libs',
chunks: 'all',
enforce: true
}
}
}
},
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
plugins: [
new HappyPack({
id: 'js',
... ... @@ -162,10 +171,6 @@ module.exports = (env) => {
threadPool: happyThreadPool,
loaders: [hbsLoader]
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'libs',
filename: 'libs.js'
}),
new webpack.ProvidePlugin({
$: 'yoho-jquery',
jQuery: 'yoho-jquery',
... ...
... ... @@ -10,10 +10,15 @@ let baseConfig = require('./webpack.base.config.js');
baseConfig = baseConfig('dev');
_.mergeWith(baseConfig, {
mode: 'development',
devtool: '#cheap-module-source-map',
output: {
publicPath: devInfo.publicPath
},
performance: {
maxEntrypointSize: 2048000,
maxAssetSize: 2048000
},
devServer: {
host: '127.0.0.1',
port: devInfo.port,
... ...
'use strict';
const os = require('os');
const path = require('path');
const shelljs = require('shelljs');
const _ = require('lodash');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = require('../../package.json');
const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`);
... ... @@ -18,34 +16,12 @@ shelljs.cp('-R', path.join(__dirname, '../font/'), distDir);
baseConfig = baseConfig('pro');
_.mergeWith(baseConfig, {
mode: 'production',
output: {
path: distDir
},
plugins: [
new ExtractTextPlugin('[name].css'),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
workers: os.cpus().length,
ie8: true,
compress: {
screw_ie8: false,
properties: false,
warnings: false
},
output: {
screw_ie8: false,
keep_quoted_props: true
},
mangle: {
screw_ie8: false
},
comments: false,
sourceMap: true
})
new ExtractTextPlugin('[name].css')
]
}, function customizer(objValue, srcValue) {
if (_.isArray(objValue)) {
... ...
const $ = require('yoho-jquery');
// 注册ajaxError处理服务端异常
$(document).ajaxError((event, xhr) => {
if (xhr.responseJSON) {
if (xhr.status === 510 && xhr.responseJSON.data && xhr.responseJSON.data.refer) {
window.location.href = xhr.responseJSON.data.refer;
}
}
});
console.log('global running');
// const $ = require('yoho-jquery');
// // 注册ajaxError处理服务端异常
// $(document).ajaxError((event, xhr) => {
// if (xhr.responseJSON) {
// if (xhr.status === 510 && xhr.responseJSON.data && xhr.responseJSON.data.refer) {
// window.location.href = xhr.responseJSON.data.refer;
// }
// }
// });
... ...
This diff could not be displayed because it is too large.