[Improvement] upgrade to webpack 4 (#693)

This commit is contained in:
neverland
2018-03-15 10:13:48 +08:00
committed by GitHub
parent 461b6732eb
commit f13a0779fd
18 changed files with 6384 additions and 4220 deletions

View File

@@ -3,16 +3,10 @@ const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const cache = {
loader: 'cache-loader',
options: {
cacheDirectory: path.resolve(__dirname, '../node_modules/.cache-loader')
}
};
module.exports = {
mode: 'development',
entry: {
'vant-docs': './docs/src/index.js',
'vant-mobile': './docs/src/mobile.js'
@@ -20,7 +14,6 @@ module.exports = {
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: '/',
filename: '[name].js',
chunkFilename: 'async_[name].js'
},
devServer: {
@@ -34,21 +27,17 @@ module.exports = {
stats: 'errors-only'
},
resolve: {
modules: [path.join(__dirname, '../node_modules'), 'node_modules'],
extensions: ['.js', '.vue', '.css'],
alias: {
vue: 'vue/dist/vue.runtime.esm.js',
packages: path.join(__dirname, '../packages'),
lib: path.join(__dirname, '../lib'),
components: path.join(__dirname, '../docs/src/components')
packages: path.join(__dirname, '../packages')
}
},
module: {
loaders: [
rules: [
{
test: /\.vue$/,
use: [
cache,
{
loader: 'vue-loader',
options: {
@@ -61,10 +50,7 @@ module.exports = {
{
test: /\.js$/,
exclude: /node_modules|vue-router\/|vue-loader\//,
use: [
cache,
'babel-loader'
]
use: 'babel-loader'
},
{
test: /\.css$/,
@@ -78,7 +64,6 @@ module.exports = {
{
test: /\.md/,
use: [
cache,
'vue-loader',
'fast-vue-md-loader'
]
@@ -103,15 +88,9 @@ module.exports = {
filename: 'examples.html',
inject: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: 2,
filename: isProduction ? 'vendor.[hash:8].js' : 'vendor.js'
}),
new ExtractTextPlugin({
filename: isProduction ? '[name].[hash:8].css' : '[name].css',
allChunks: true
}),
new FriendlyErrorsPlugin()
})
]
};