2016-10-13 06:27:58 +00:00
|
|
|
import webpack from 'webpack';
|
2016-10-13 07:29:09 +00:00
|
|
|
import path from 'path';
|
2016-10-13 06:27:58 +00:00
|
|
|
import merge from 'webpack-merge';
|
2016-12-23 20:36:53 +00:00
|
|
|
import autoprefixer from 'autoprefixer';
|
2016-10-13 06:27:58 +00:00
|
|
|
import ExtractTextPlugin from 'extract-text-webpack-plugin';
|
2016-10-17 06:33:00 +00:00
|
|
|
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
2016-10-13 06:27:58 +00:00
|
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
2016-12-26 15:18:29 +00:00
|
|
|
import OptimizeJsPlugin from 'optimize-js-plugin';
|
2017-02-08 23:27:50 +00:00
|
|
|
import OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin';
|
|
|
|
|
import mediaPacker from 'css-mqpacker';
|
2016-10-13 06:27:58 +00:00
|
|
|
import config from '../config';
|
2016-10-13 07:29:09 +00:00
|
|
|
import baseConfig from './base';
|
2016-10-13 06:27:58 +00:00
|
|
|
|
2016-12-26 15:18:29 +00:00
|
|
|
const docsPath = path.join(config.rootPath, config.docsPath);
|
2016-10-13 07:29:09 +00:00
|
|
|
|
2017-02-07 22:49:51 +00:00
|
|
|
const conf = merge(baseConfig, {
|
2016-10-13 07:29:09 +00:00
|
|
|
output: {
|
2016-12-26 15:18:29 +00:00
|
|
|
path: docsPath,
|
2016-10-14 17:53:39 +00:00
|
|
|
publicPath: '',
|
2016-10-13 07:29:09 +00:00
|
|
|
filename: '[name].[chunkhash:8].js',
|
2016-12-23 21:13:57 +00:00
|
|
|
chunkFilename: '[name].[chunkhash:8].js'
|
2016-10-13 07:29:09 +00:00
|
|
|
},
|
2017-02-07 21:24:29 +00:00
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.vue$/,
|
|
|
|
|
loader: 'vue-loader',
|
|
|
|
|
options: {
|
|
|
|
|
loaders: {
|
2017-02-07 22:49:51 +00:00
|
|
|
css: ExtractTextPlugin.extract({
|
|
|
|
|
use: 'css-loader',
|
|
|
|
|
fallback: 'vue-style-loader'
|
|
|
|
|
}),
|
|
|
|
|
scss: ExtractTextPlugin.extract({
|
|
|
|
|
use: 'css-loader!sass-loader',
|
|
|
|
|
fallback: 'vue-style-loader'
|
|
|
|
|
})
|
2017-02-07 21:24:29 +00:00
|
|
|
},
|
|
|
|
|
postcss: [
|
|
|
|
|
autoprefixer({
|
2017-02-08 21:10:28 +00:00
|
|
|
browsers: ['last 3 versions', 'not IE < 10']
|
2017-02-08 23:27:50 +00:00
|
|
|
}),
|
|
|
|
|
mediaPacker()
|
2017-02-07 21:24:29 +00:00
|
|
|
]
|
|
|
|
|
}
|
2017-02-07 22:49:51 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
loader: ExtractTextPlugin.extract({
|
|
|
|
|
use: 'css-loader',
|
|
|
|
|
fallback: 'vue-style-loader'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.scss$/,
|
|
|
|
|
loader: ExtractTextPlugin.extract({
|
|
|
|
|
use: 'css-loader!sass-loader',
|
|
|
|
|
fallback: 'vue-style-loader'
|
|
|
|
|
})
|
2017-02-07 21:24:29 +00:00
|
|
|
}
|
2016-12-23 20:36:53 +00:00
|
|
|
]
|
2016-10-13 06:27:58 +00:00
|
|
|
},
|
|
|
|
|
plugins: [
|
2017-02-07 21:24:29 +00:00
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
|
minimize: true,
|
2017-02-07 22:49:51 +00:00
|
|
|
debug: true
|
2017-02-07 21:24:29 +00:00
|
|
|
}),
|
2016-10-13 06:27:58 +00:00
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
|
compress: {
|
2017-02-21 21:46:58 +00:00
|
|
|
warnings: false,
|
|
|
|
|
screw_ie8: true,
|
|
|
|
|
conditionals: true,
|
|
|
|
|
unused: true,
|
|
|
|
|
comparisons: true,
|
|
|
|
|
sequences: true,
|
|
|
|
|
dead_code: true,
|
|
|
|
|
evaluate: true,
|
|
|
|
|
join_vars: true,
|
|
|
|
|
if_return: true
|
2016-12-26 15:18:29 +00:00
|
|
|
},
|
2017-02-07 21:24:29 +00:00
|
|
|
output: {
|
|
|
|
|
comments: false
|
|
|
|
|
},
|
|
|
|
|
sourceMap: false
|
2016-12-26 15:18:29 +00:00
|
|
|
}),
|
|
|
|
|
new OptimizeJsPlugin({
|
|
|
|
|
sourceMap: false
|
2016-10-13 06:27:58 +00:00
|
|
|
}),
|
2017-02-07 22:49:51 +00:00
|
|
|
new ExtractTextPlugin('[name].[contenthash:8].css'),
|
2016-10-17 06:33:00 +00:00
|
|
|
new CopyWebpackPlugin([
|
|
|
|
|
{
|
|
|
|
|
context: config.assetsPath,
|
|
|
|
|
from: '**/*',
|
2016-12-26 15:18:29 +00:00
|
|
|
to: path.join(docsPath, 'assets')
|
2016-12-14 21:22:04 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
context: config.docsPath,
|
|
|
|
|
from: 'changelog.html',
|
2016-12-26 15:18:29 +00:00
|
|
|
to: docsPath
|
2016-12-14 21:22:04 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
context: config.docsPath,
|
2016-12-14 21:31:33 +00:00
|
|
|
from: 'versions.json',
|
2016-12-26 15:18:29 +00:00
|
|
|
to: docsPath
|
2016-10-17 06:33:00 +00:00
|
|
|
}
|
|
|
|
|
]),
|
2016-10-13 06:27:58 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
|
filename: 'index.html',
|
|
|
|
|
template: config.indexPath,
|
|
|
|
|
inject: true,
|
|
|
|
|
minify: {
|
|
|
|
|
caseSensitive: true,
|
|
|
|
|
collapseBooleanAttributes: true,
|
|
|
|
|
collapseWhitespace: true,
|
|
|
|
|
minifyCSS: true,
|
|
|
|
|
minifyJS: true,
|
|
|
|
|
preventAttributesEscaping: true,
|
|
|
|
|
removeAttributeQuotes: true,
|
|
|
|
|
removeComments: true,
|
|
|
|
|
removeCommentsFromCDATA: true,
|
|
|
|
|
removeEmptyAttributes: true,
|
|
|
|
|
removeOptionalTags: true,
|
|
|
|
|
removeRedundantAttributes: true,
|
|
|
|
|
removeScriptTypeAttributes: true,
|
|
|
|
|
removeStyleLinkTypeAttributes: true,
|
|
|
|
|
useShortDoctype: true
|
|
|
|
|
},
|
|
|
|
|
chunksSortMode: 'dependency'
|
2016-10-13 07:29:09 +00:00
|
|
|
}),
|
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
2016-11-16 05:05:35 +00:00
|
|
|
name: 'vendor',
|
2016-12-26 15:18:29 +00:00
|
|
|
minChunks(module) {
|
2016-10-13 07:29:09 +00:00
|
|
|
let resource = module.resource;
|
|
|
|
|
|
2016-12-26 15:18:29 +00:00
|
|
|
if (resource && (/\.js$/).test(resource)) {
|
|
|
|
|
return resource.indexOf(config.nodePath) >= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2016-10-13 07:29:09 +00:00
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
|
name: 'manifest',
|
2016-11-16 05:05:35 +00:00
|
|
|
chunks: ['vendor']
|
2017-02-08 23:27:50 +00:00
|
|
|
}),
|
2017-02-21 21:46:58 +00:00
|
|
|
new OptimizeCssAssetsPlugin({
|
|
|
|
|
canPrint: false
|
|
|
|
|
})
|
2016-10-13 06:27:58 +00:00
|
|
|
]
|
|
|
|
|
});
|
2017-02-07 22:49:51 +00:00
|
|
|
|
|
|
|
|
export default conf;
|