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';
|
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
|
|
|
|
|
|
|
|
export default merge(baseConfig, {
|
|
|
|
|
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
|
|
|
},
|
2016-10-13 06:27:58 +00:00
|
|
|
vue: {
|
|
|
|
|
loaders: {
|
|
|
|
|
css: ExtractTextPlugin.extract('css'),
|
2017-01-08 17:50:26 +00:00
|
|
|
scss: ExtractTextPlugin.extract('css!sass')
|
2016-12-23 20:36:53 +00:00
|
|
|
},
|
|
|
|
|
postcss: [
|
|
|
|
|
autoprefixer({
|
|
|
|
|
browsers: ['last 3 versions']
|
|
|
|
|
})
|
|
|
|
|
]
|
2016-10-13 06:27:58 +00:00
|
|
|
},
|
|
|
|
|
plugins: [
|
2016-12-26 15:18:29 +00:00
|
|
|
new webpack.optimize.DedupePlugin(),
|
2016-10-13 06:27:58 +00:00
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
|
compress: {
|
|
|
|
|
warnings: false
|
2016-12-26 15:18:29 +00:00
|
|
|
},
|
|
|
|
|
comments: false
|
|
|
|
|
}),
|
|
|
|
|
new OptimizeJsPlugin({
|
|
|
|
|
sourceMap: false
|
2016-10-13 06:27:58 +00:00
|
|
|
}),
|
2016-10-13 07:29:09 +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']
|
2016-12-26 15:18:29 +00:00
|
|
|
}),
|
|
|
|
|
new webpack.optimize.OccurenceOrderPlugin()
|
2016-10-13 06:27:58 +00:00
|
|
|
]
|
|
|
|
|
});
|