var webpack = require('webpack'); var path = require('path'); var slugify = require('transliteration').slugify; var striptags = require('./strip-tags'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var getPostcssPlugin = require('./utils/postcss_pipe'); var ProgressBarPlugin = require('progress-bar-webpack-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') const isProduction = process.env.NODE_ENV === 'production'; const watchExample = require('./genExamples'); if (!isProduction) { watchExample(); } var StyleExtractPlugin; if (process.env.NODE_ENV === 'production') { StyleExtractPlugin = new ExtractTextPlugin('[name].[hash:8].css'); } else { StyleExtractPlugin = new ExtractTextPlugin('[name].css'); } function convert(str) { str = str.replace(/(&#x)(\w{4});/gi, function($0) { return String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16)); }); return str; } function wrap(render) { return function() { return render.apply(this, arguments) .replace(/\
`; } return `
\n`; } }] ], preprocess: function(MarkdownIt, source) { MarkdownIt.renderer.rules.table_open = function() { return ''; }; return source; } } } }), new HtmlWebpackPlugin({ chunks: ['vendor', 'vant-docs'], template: 'docs/src/index.tpl', filename: 'index.html', inject: true }), new HtmlWebpackPlugin({ chunks: ['vendor', 'vant-examples'], template: 'docs/src/index.tpl', filename: 'examples.html', inject: true }), new webpack.HotModuleReplacementPlugin(), new OptimizeCssAssetsPlugin(), StyleExtractPlugin, new FriendlyErrorsPlugin() ] };