feat(cli): add cache-loader

This commit is contained in:
陈嘉涵
2020-01-05 14:48:16 +08:00
parent 25042b7db5
commit 131508bbc1
4 changed files with 56 additions and 19 deletions

View File

@@ -26,6 +26,7 @@ export const WEBPACK_CONFIG_FILE = join(ROOT, 'webpack.config.js');
export const DIST_DIR = join(__dirname, '../../dist');
export const CONFIG_DIR = join(__dirname, '../config');
export const CACHE_DIR = join(ROOT, 'node_modules/.cache');
export const PACKAGE_ENTRY_FILE = join(DIST_DIR, 'package-entry.js');
export const PACKAGE_STYLE_FILE = join(DIST_DIR, 'package-style.css');

View File

@@ -3,11 +3,19 @@ import FriendlyErrorsPlugin from '@nuxt/friendly-errors-webpack-plugin';
import sass from 'sass';
import { VueLoaderPlugin } from 'vue-loader';
import {
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',
@@ -31,6 +39,7 @@ export const baseConfig = {
{
test: /\.vue$/,
use: [
CACHE_LOADER,
{
loader: 'vue-loader',
options: {
@@ -44,9 +53,7 @@ export const baseConfig = {
{
test: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules\/(?!(@vant\/cli))/,
use: {
loader: 'babel-loader'
}
use: [CACHE_LOADER, 'babel-loader']
},
{
test: /\.css$/,
@@ -56,12 +63,7 @@ export const baseConfig = {
{
test: /\.less$/,
sideEffects: true,
use: [
...CSS_LOADERS,
{
loader: 'less-loader'
}
]
use: [...CSS_LOADERS, 'less-loader']
},
{
test: /\.scss$/,
@@ -78,7 +80,7 @@ export const baseConfig = {
},
{
test: /\.md$/,
use: ['vue-loader', '@vant/markdown-loader']
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader']
}
]
},