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

@ -64,6 +64,7 @@
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-import": "^1.13.0",
"cache-loader": "^4.1.0",
"chokidar": "^3.3.1",
"clean-css": "^4.2.1",
"codecov": "^3.6.1",

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']
}
]
},

View File

@ -2698,6 +2698,11 @@ buffer-indexof@^1.0.0:
resolved "https://registry.npm.taobao.org/buffer-indexof/download/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c"
integrity sha1-Uvq8xqYG0aADAoAmSO9o9jnaJow=
buffer-json@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/buffer-json/download/buffer-json-2.0.0.tgz#f73e13b1e42f196fe2fd67d001c7d7107edd7c23"
integrity sha1-9z4TseQvGW/i/WfQAcfXEH7dfCM=
buffer-xor@^1.0.3:
version "1.0.3"
resolved "https://registry.npm.taobao.org/buffer-xor/download/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9"
@ -2763,6 +2768,18 @@ cache-base@^1.0.1:
union-value "^1.0.0"
unset-value "^1.0.0"
cache-loader@^4.1.0:
version "4.1.0"
resolved "https://registry.npm.taobao.org/cache-loader/download/cache-loader-4.1.0.tgz#9948cae353aec0a1fcb1eafda2300816ec85387e"
integrity sha1-mUjK41OuwKH8ser9ojAIFuyFOH4=
dependencies:
buffer-json "^2.0.0"
find-cache-dir "^3.0.0"
loader-utils "^1.2.3"
mkdirp "^0.5.1"
neo-async "^2.6.1"
schema-utils "^2.0.0"
cacheable-request@^6.0.0:
version "6.1.0"
resolved "https://registry.npm.taobao.org/cacheable-request/download/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912"
@ -4912,6 +4929,15 @@ find-cache-dir@^2.0.0, find-cache-dir@^2.1.0:
make-dir "^2.0.0"
pkg-dir "^3.0.0"
find-cache-dir@^3.0.0:
version "3.2.0"
resolved "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.2.0.tgz#e7fe44c1abc1299f516146e563108fd1006c1874"
integrity sha1-5/5EwavBKZ9RYUblYxCP0QBsGHQ=
dependencies:
commondir "^1.0.1"
make-dir "^3.0.0"
pkg-dir "^4.1.0"
find-up@4.1.0, find-up@^4.0.0:
version "4.1.0"
resolved "https://registry.npm.taobao.org/find-up/download/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
@ -7375,6 +7401,13 @@ make-dir@^2.0.0, make-dir@^2.1.0:
pify "^4.0.1"
semver "^5.6.0"
make-dir@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/make-dir/download/make-dir-3.0.0.tgz#1b5f39f6b9270ed33f9f054c5c0f84304989f801"
integrity sha1-G1859rknDtM/nwVMXA+EMEmJ+AE=
dependencies:
semver "^6.0.0"
make-error@1.x:
version "1.3.5"
resolved "https://registry.npm.taobao.org/make-error/download/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
@ -8684,7 +8717,7 @@ pkg-dir@^3.0.0:
dependencies:
find-up "^3.0.0"
pkg-dir@^4.2.0:
pkg-dir@^4.1.0, pkg-dir@^4.2.0:
version "4.2.0"
resolved "https://registry.npm.taobao.org/pkg-dir/download/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3"
integrity sha1-8JkTPfft5CLoHR2ESCcO6z5CYfM=
@ -9834,18 +9867,18 @@ schema-utils@^1.0.0:
ajv-errors "^1.0.0"
ajv-keywords "^3.1.0"
schema-utils@^2.0.1, schema-utils@^2.1.0:
version "2.5.0"
resolved "https://registry.npm.taobao.org/schema-utils/download/schema-utils-2.5.0.tgz?cache=0&sync_timestamp=1571141316329&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fschema-utils%2Fdownload%2Fschema-utils-2.5.0.tgz#8f254f618d402cc80257486213c8970edfd7c22f"
integrity sha1-jyVPYY1ALMgCV0hiE8iXDt/Xwi8=
schema-utils@^2.0.0, schema-utils@^2.6.0:
version "2.6.1"
resolved "https://registry.npm.taobao.org/schema-utils/download/schema-utils-2.6.1.tgz?cache=0&sync_timestamp=1574946791935&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fschema-utils%2Fdownload%2Fschema-utils-2.6.1.tgz#eb78f0b945c7bcfa2082b3565e8db3548011dc4f"
integrity sha1-63jwuUXHvPoggrNWXo2zVIAR3E8=
dependencies:
ajv "^6.10.2"
ajv-keywords "^3.4.1"
schema-utils@^2.6.0:
version "2.6.1"
resolved "https://registry.npm.taobao.org/schema-utils/download/schema-utils-2.6.1.tgz?cache=0&sync_timestamp=1574946791935&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fschema-utils%2Fdownload%2Fschema-utils-2.6.1.tgz#eb78f0b945c7bcfa2082b3565e8db3548011dc4f"
integrity sha1-63jwuUXHvPoggrNWXo2zVIAR3E8=
schema-utils@^2.0.1, schema-utils@^2.1.0:
version "2.5.0"
resolved "https://registry.npm.taobao.org/schema-utils/download/schema-utils-2.5.0.tgz?cache=0&sync_timestamp=1571141316329&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fschema-utils%2Fdownload%2Fschema-utils-2.5.0.tgz#8f254f618d402cc80257486213c8970edfd7c22f"
integrity sha1-jyVPYY1ALMgCV0hiE8iXDt/Xwi8=
dependencies:
ajv "^6.10.2"
ajv-keywords "^3.4.1"