build: add files of vant-cli 2
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
module.exports = function(api: any) {
|
||||
const { BABEL_MODULE, NODE_ENV } = process.env;
|
||||
|
||||
const isTest = NODE_ENV === 'test';
|
||||
const useESModules = BABEL_MODULE !== 'commonjs' && !isTest;
|
||||
|
||||
api && api.cache(false);
|
||||
|
||||
return {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
loose: true,
|
||||
modules: useESModules ? false : 'commonjs'
|
||||
}
|
||||
],
|
||||
[
|
||||
'@vue/babel-preset-jsx',
|
||||
{
|
||||
functional: false
|
||||
}
|
||||
],
|
||||
'@babel/preset-typescript'
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
{
|
||||
corejs: false,
|
||||
helpers: true,
|
||||
regenerator: isTest,
|
||||
useESModules
|
||||
}
|
||||
],
|
||||
'@babel/plugin-transform-object-assign',
|
||||
'@babel/plugin-proposal-optional-chaining'
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default module.exports;
|
||||
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
JEST_FILE_MOCK_FILE,
|
||||
JEST_STYLE_MOCK_FILE
|
||||
} from '../common/constant';
|
||||
|
||||
module.exports = {
|
||||
moduleNameMapper: {
|
||||
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
|
||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE
|
||||
},
|
||||
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
||||
transform: {
|
||||
'\\.(vue)$': 'vue-jest',
|
||||
'\\.(js|jsx|ts|tsx)$': 'babel-jest'
|
||||
},
|
||||
transformIgnorePatterns: ['node_modules/(?!(vant|@babel\\/runtime)/)'],
|
||||
snapshotSerializers: ['jest-serializer-vue'],
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{js,jsx,ts,tsx,vue}',
|
||||
'!**/style/**',
|
||||
'!**/demo/**',
|
||||
'!**/locale/lang/**',
|
||||
'!**/sku/**'
|
||||
],
|
||||
collectCoverage: true,
|
||||
coverageReporters: ['html', 'lcov', 'text-summary'],
|
||||
coverageDirectory: './test/coverage'
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = 'test-file-stub';
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = {};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
autoprefixer: {}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,78 @@
|
||||
|
||||
import sass from 'sass';
|
||||
import { VueLoaderPlugin } from 'vue-loader';
|
||||
import { POSTCSS_CONFIG_FILE } from '../common/constant';
|
||||
|
||||
const CSS_LOADERS = [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
config: {
|
||||
path: POSTCSS_CONFIG_FILE
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.tsx', '.jsx', '.vue', '.less']
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.vue$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
compilerOptions: {
|
||||
preserveWhitespace: false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.(js|ts|jsx|tsx)$/,
|
||||
exclude: /node_modules\/(?!(@youzan\/create-vue-components))/,
|
||||
use: {
|
||||
loader: 'babel-loader'
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
sideEffects: true,
|
||||
use: CSS_LOADERS
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
sideEffects: true,
|
||||
use: [...CSS_LOADERS, 'less-loader']
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
sideEffects: true,
|
||||
use: [
|
||||
...CSS_LOADERS,
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
implementation: sass
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.md$/,
|
||||
use: ['vue-loader', '@vant/markdown-loader']
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [new VueLoaderPlugin()]
|
||||
};
|
||||
|
||||
export default module.exports;
|
||||
@@ -0,0 +1,48 @@
|
||||
import { join } from 'path';
|
||||
import merge from 'webpack-merge';
|
||||
import config from './webpack.base';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
|
||||
module.exports = merge(config, {
|
||||
entry: {
|
||||
'site-desktop': join(__dirname, '../../site/desktop/main.js'),
|
||||
'site-mobile': join(__dirname, '../../site/mobile/main.js')
|
||||
},
|
||||
devServer: {
|
||||
open: true,
|
||||
host: '0.0.0.0',
|
||||
stats: 'errors-only',
|
||||
disableHostCheck: true,
|
||||
},
|
||||
output: {
|
||||
path: join(__dirname, '../../site/dist'),
|
||||
publicPath: '/',
|
||||
chunkFilename: 'async_[name].js'
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
chunks: {
|
||||
chunks: 'all',
|
||||
minChunks: 2,
|
||||
minSize: 0,
|
||||
name: 'chunks'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
chunks: ['chunks', 'site-desktop'],
|
||||
template: join(__dirname, '../../site/desktop/index.html'),
|
||||
filename: 'index.html'
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
chunks: ['chunks', 'site-mobile'],
|
||||
template: join(__dirname, '../../site/mobile/index.html'),
|
||||
filename: 'mobile.html'
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
export default module.exports;
|
||||
@@ -0,0 +1,15 @@
|
||||
import { join } from 'path';
|
||||
import merge from 'webpack-merge';
|
||||
import config from './webpack.site.dev';
|
||||
|
||||
module.exports = merge(config, {
|
||||
mode: 'production',
|
||||
output: {
|
||||
path: join(__dirname, '../../site/dist'),
|
||||
publicPath: 'https://b.yzcdn.cn/vant/',
|
||||
filename: '[name].[hash:8].js',
|
||||
chunkFilename: 'async_[name].[chunkhash:8].js'
|
||||
}
|
||||
});
|
||||
|
||||
export default module.exports;
|
||||
Reference in New Issue
Block a user