...
|
...
|
@@ -5,20 +5,24 @@ |
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const webpack = require('webpack');
|
|
|
const path = require('path');
|
|
|
const _ = require('lodash');
|
|
|
const os = require('os');
|
|
|
const path = require('path');
|
|
|
const scss = require('postcss-scss');
|
|
|
const shelljs = require('shelljs');
|
|
|
const webpack = require('webpack');
|
|
|
const HappyPack = require('happypack');
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
const StyleLintPlugin = require('stylelint-webpack-plugin');
|
|
|
const postcssConfig = require('./postcss.config.js');
|
|
|
const scss = require('postcss-scss');
|
|
|
|
|
|
const entries = {
|
|
|
'index': path.join(__dirname, '../scss/index.css'),
|
|
|
'common': path.join(__dirname, '../scss/common.css'),
|
|
|
'feature': path.join(__dirname, '../scss/feature.css')
|
|
|
index: path.join(__dirname, '../scss/index.css'),
|
|
|
common: path.join(__dirname, '../scss/common.css'),
|
|
|
feature: path.join(__dirname, '../scss/feature.css')
|
|
|
};
|
|
|
const happyThreadPool = HappyPack.ThreadPool({ // eslint-disable-line
|
|
|
size: os.cpus().length
|
|
|
});
|
|
|
|
|
|
// 构建各模块子页面JS。生成规则module.page.js
|
|
|
shelljs.ls(path.join(__dirname, '../js/**/*.page.js')).forEach((f) => {
|
...
|
...
|
@@ -67,7 +71,7 @@ module.exports = (env) => { |
|
|
test: /\.js$/,
|
|
|
exclude: [/node_modules/],
|
|
|
use: [{
|
|
|
loader: 'babel-loader'
|
|
|
loader: 'happypack/loader?id=js'
|
|
|
}]
|
|
|
}, {
|
|
|
test: /\.css$/,
|
...
|
...
|
@@ -89,22 +93,18 @@ module.exports = (env) => { |
|
|
}, {
|
|
|
test: /\.hbs$/,
|
|
|
use: [{
|
|
|
loader: 'handlebars-loader',
|
|
|
options: {
|
|
|
helperDirs: [
|
|
|
path.join(__dirname, '../js/common/helpers')
|
|
|
],
|
|
|
partialDirs: [
|
|
|
path.join(__dirname, '../../doraemon/views/partial')
|
|
|
]
|
|
|
}
|
|
|
loader: 'happypack/loader?id=hbs',
|
|
|
}]
|
|
|
}]
|
|
|
},
|
|
|
resolve: {
|
|
|
modules: ['node_modules', './public/vue', './public/hbs', './public/scss', './public/js'],
|
|
|
modules: [path.join(__dirname, '../../node_modules'),
|
|
|
path.join(__dirname, '../vue'),
|
|
|
path.join(__dirname, '../hbs'),
|
|
|
path.join(__dirname, '../scss'),
|
|
|
path.join(__dirname, '../js')
|
|
|
],
|
|
|
alias: {
|
|
|
js: path.join(__dirname, '../js/'),
|
|
|
vue: 'vue/dist/vue.js'
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -112,6 +112,29 @@ module.exports = (env) => { |
|
|
children: false
|
|
|
},
|
|
|
plugins: [
|
|
|
new StyleLintPlugin({
|
|
|
files: ['public/scss/*.css', 'public/scss/**/*.css', 'public/vue/*.vue', 'public/vue/**/*.vue']
|
|
|
}),
|
|
|
new HappyPack({
|
|
|
id: 'js',
|
|
|
threadPool: happyThreadPool,
|
|
|
loaders: ['babel-loader'],
|
|
|
}),
|
|
|
new HappyPack({
|
|
|
id: 'hbs',
|
|
|
threadPool: happyThreadPool,
|
|
|
loaders: [{
|
|
|
loader: 'handlebars-loader',
|
|
|
options: {
|
|
|
helperDirs: [
|
|
|
path.join(__dirname, '../js/common/helpers')
|
|
|
],
|
|
|
partialDirs: [
|
|
|
path.join(__dirname, '../../doraemon/views/partial')
|
|
|
]
|
|
|
}
|
|
|
}]
|
|
|
}),
|
|
|
new ExtractTextPlugin('[name].css'),
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
name: 'libs',
|
...
|
...
|
@@ -123,5 +146,5 @@ module.exports = (env) => { |
|
|
'window.jQuery': 'yoho-jquery'
|
|
|
})
|
|
|
]
|
|
|
}
|
|
|
};
|
|
|
}; |
...
|
...
|
|