vue-material/build/webpack/prod-docs.js

103 lines
2.6 KiB
JavaScript
Raw Normal View History

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';
import CopyWebpackPlugin from 'copy-webpack-plugin';
2016-10-13 06:27:58 +00:00
import HtmlWebpackPlugin from 'html-webpack-plugin';
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
const docsPath = path.join(config.rootPath, config.docsPath);
2016-10-13 07:29:09 +00:00
export default merge(baseConfig, {
output: {
path: docsPath,
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: [
new webpack.optimize.DedupePlugin(),
2016-10-13 06:27:58 +00:00
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
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'),
new CopyWebpackPlugin([
{
context: config.assetsPath,
from: '**/*',
to: path.join(docsPath, 'assets')
},
{
context: config.docsPath,
from: 'changelog.html',
to: docsPath
},
{
context: config.docsPath,
2016-12-14 21:31:33 +00:00
from: 'versions.json',
to: docsPath
}
]),
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',
minChunks(module) {
2016-10-13 07:29:09 +00:00
let resource = module.resource;
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']
}),
new webpack.optimize.OccurenceOrderPlugin()
2016-10-13 06:27:58 +00:00
]
});