[Build] revert site to webpack config (#3747)

This commit is contained in:
neverland
2019-07-04 14:26:20 +08:00
committed by GitHub
parent 6c0f05d5cc
commit 75525ae410
37 changed files with 1326 additions and 8236 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ const tasks = [
'node build/build-components.js --color',
'node build/build-style.js',
'node build/build-style-entry.js',
'cross-env NODE_ENV=production webpack --color --config build/webpack.config.js',
'cross-env NODE_ENV=production webpack -p --color --config build/webpack.config.js'
'cross-env NODE_ENV=production webpack --color --config build/webpack.build.js',
'cross-env NODE_ENV=production webpack -p --color --config build/webpack.build.js'
];
tasks.forEach(task => {
@@ -1,8 +1,11 @@
const path = require('path');
const config = require('./webpack.dev.js');
const isMinify = process.argv.indexOf('-p') !== -1;
module.exports = {
delete config.serve;
module.exports = Object.assign(config, {
mode: 'production',
entry: {
vant: './es/index.js'
@@ -23,19 +26,8 @@ module.exports = {
amd: 'vue'
}
},
performance: false,
optimization: {
minimize: isMinify
},
resolve: {
extensions: ['.js', '.ts', '.tsx']
},
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
}
};
});
+87
View File
@@ -0,0 +1,87 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const { VueLoaderPlugin } = require('vue-loader');
module.exports = {
mode: 'development',
entry: {
'vant-docs': './docs/site/desktop/main.js',
'vant-mobile': './docs/site/mobile/main.js'
},
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: '/',
chunkFilename: 'async_[name].js'
},
stats: {
modules: false,
children: false
},
devServer: {
open: true,
host: '0.0.0.0',
stats: 'errors-only',
clientLogLevel: 'warning'
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.vue', '.less']
},
module: {
rules: [
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false
}
}
}
]
},
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.less$/,
sideEffects: true,
use: [
'style-loader',
'css-loader',
'postcss-loader',
{
loader: 'less-loader',
options: {
paths: [path.resolve(__dirname, 'node_modules')]
}
}
]
},
{
test: /\.md$/,
use: ['vue-loader', '@vant/markdown-loader']
}
]
},
plugins: [
new VueLoaderPlugin(),
new ProgressBarPlugin(),
new HtmlWebpackPlugin({
chunks: ['vant-docs'],
template: 'docs/site/desktop/index.html',
filename: 'index.html',
inject: true
}),
new HtmlWebpackPlugin({
chunks: ['vant-mobile'],
template: 'docs/site/mobile/index.html',
filename: 'mobile.html',
inject: true
})
]
};
+12
View File
@@ -0,0 +1,12 @@
const path = require('path');
const config = require('./webpack.dev.js');
module.exports = Object.assign(config, {
mode: 'production',
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: 'https://youzan.github.io/vant/',
filename: '[name].[hash:8].js',
chunkFilename: 'async_[name].[chunkhash:8].js'
}
});