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

153 lines
3.8 KiB
JavaScript
Raw Permalink 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';
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
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: {
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
},
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']
}),
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: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
join_vars: true,
if_return: true
},
2017-02-07 21:24:29 +00:00
output: {
comments: false
},
sourceMap: false
}),
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'),
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 OptimizeCssAssetsPlugin({
canPrint: false
})
2016-10-13 06:27:58 +00:00
]
});
2017-02-07 22:49:51 +00:00
export default conf;