feat(cli): bump webpack@5

This commit is contained in:
chenjiahan
2020-10-13 19:15:32 +08:00
parent 438dcbc0ff
commit 30c24ba23f
8 changed files with 315 additions and 817 deletions

View File

@@ -6,7 +6,7 @@ export async function compilePackage(isMinify: boolean) {
const config = getPackageConfig(isMinify);
webpack(config, (err, stats) => {
if (err || stats.hasErrors()) {
if (err || (stats && stats.hasErrors())) {
reject();
} else {
resolve();

View File

@@ -24,7 +24,7 @@ function runDevServer(
const server = new WebpackDevServer(webpack(config), config.devServer);
// this is a hack to disable wds status log
(server as any).showStatus = function() {};
(server as any).showStatus = function () {};
const host = get(config.devServer, 'host', 'localhost');
server.listen(port, host, (err?: Error) => {
@@ -58,7 +58,7 @@ function build() {
const config = getSitePrdConfig();
webpack(config, (err, stats) => {
if (err || stats.hasErrors()) {
if (err || (stats && stats.hasErrors())) {
reject();
} else {
resolve();

View File

@@ -10,7 +10,7 @@ import { PACKAGE_ENTRY_FILE, PACKAGE_STYLE_FILE } from '../common/constant';
const PLUGIN_NAME = 'VantCliSitePlugin';
export async function genSiteEntry() {
export async function genSiteEntry(): Promise<void> {
return new Promise((resolve, reject) => {
genStyleDepsMap()
.then(() => {
@@ -24,7 +24,7 @@ export async function genSiteEntry() {
genSiteDesktopShared();
resolve();
})
.catch(err => {
.catch((err) => {
console.log(err);
reject(err);
});

View File

@@ -8,19 +8,11 @@ import { existsSync } from 'fs';
import { WebpackConfig } from '../common/types';
import {
CWD,
CACHE_DIR,
STYLE_EXTS,
SCRIPT_EXTS,
POSTCSS_CONFIG_FILE,
} from '../common/constant';
const CACHE_LOADER = {
loader: 'cache-loader',
options: {
cacheDirectory: CACHE_DIR,
},
};
const CSS_LOADERS = [
'style-loader',
'css-loader',
@@ -85,7 +77,6 @@ export const baseConfig: WebpackConfig = {
{
test: /\.vue$/,
use: [
CACHE_LOADER,
{
loader: 'vue-loader',
options: {
@@ -99,7 +90,7 @@ export const baseConfig: WebpackConfig = {
{
test: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules\/(?!(@vant\/cli))/,
use: [CACHE_LOADER, 'babel-loader'],
use: ['babel-loader'],
},
{
test: /\.css$/,
@@ -126,9 +117,15 @@ export const baseConfig: WebpackConfig = {
},
{
test: /\.md$/,
use: [CACHE_LOADER, '@vant/markdown-loader'],
use: ['@vant/markdown-loader'],
},
],
},
plugins,
cache: {
type: 'filesystem',
buildDependencies: {
config: [__filename],
},
},
};