ko 5.3.8 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/build.js +47 -52
- package/lib/actions/dev.js +78 -84
- package/lib/actions/factory.js +23 -0
- package/lib/actions/lints.js +70 -0
- package/lib/cli.js +17 -33
- package/lib/core/commander.js +65 -0
- package/lib/core/config.js +56 -0
- package/lib/core/hooks.js +40 -0
- package/lib/core/service.js +23 -0
- package/lib/types.js +8 -0
- package/lib/utils/index.js +22 -0
- package/lib/webpack/index.js +98 -60
- package/lib/webpack/loaders/babel/index.js +75 -0
- package/lib/webpack/loaders/index.js +5 -1
- package/lib/webpack/loaders/script.js +48 -54
- package/lib/webpack/loaders/style.js +164 -56
- package/lib/webpack/plugins.js +63 -22
- package/package.json +33 -32
- package/lib/actions/creator.js +0 -42
- package/lib/interfaces.js +0 -2
- package/lib/utils/config.js +0 -43
package/lib/webpack/index.js
CHANGED
|
@@ -3,67 +3,105 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
8
9
|
const loaders_1 = __importDefault(require("./loaders"));
|
|
9
10
|
const plugins_1 = __importDefault(require("./plugins"));
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
class WebpackConfig {
|
|
13
|
+
constructor(service) {
|
|
14
|
+
this.extensions = [
|
|
15
|
+
'.ts',
|
|
16
|
+
'.tsx',
|
|
17
|
+
'.js',
|
|
18
|
+
'.jsx',
|
|
19
|
+
'.css',
|
|
20
|
+
'.scss',
|
|
21
|
+
'.sass',
|
|
22
|
+
'.less',
|
|
23
|
+
'.json',
|
|
24
|
+
'.html',
|
|
25
|
+
];
|
|
26
|
+
this.opts = { ...service.config, ...service.cliOpts };
|
|
27
|
+
this.env =
|
|
28
|
+
process.env.NODE_ENV === 'production' ? 'production' : 'development';
|
|
29
|
+
}
|
|
30
|
+
merge(...opts) {
|
|
31
|
+
return (0, lodash_1.merge)(this.base, ...opts);
|
|
32
|
+
}
|
|
33
|
+
get cache() {
|
|
34
|
+
const { experiment } = this.opts;
|
|
35
|
+
const type = experiment?.speedUp
|
|
36
|
+
? 'filesystem'
|
|
37
|
+
: this.isProd
|
|
38
|
+
? 'filesystem'
|
|
39
|
+
: 'memory';
|
|
40
|
+
const cache = {
|
|
41
|
+
type,
|
|
42
|
+
};
|
|
43
|
+
if (type === 'filesystem') {
|
|
44
|
+
cache.version = this.projectVersion;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
cache.maxGenerations = 1;
|
|
48
|
+
}
|
|
49
|
+
return cache;
|
|
50
|
+
}
|
|
51
|
+
get projectVersion() {
|
|
52
|
+
const pkgPath = (0, path_1.join)(this.opts.cwd, 'package.json');
|
|
53
|
+
(0, utils_1.assert)((0, fs_1.existsSync)(pkgPath), 'project package.json file not found');
|
|
54
|
+
return require(pkgPath).version;
|
|
55
|
+
}
|
|
56
|
+
get base() {
|
|
57
|
+
const { cwd, publicPath, entry, outputPath, alias, hash, analyzer } = this.opts;
|
|
58
|
+
const webpackBaseConf = {
|
|
59
|
+
mode: this.env,
|
|
60
|
+
target: 'web',
|
|
61
|
+
context: cwd,
|
|
62
|
+
entry,
|
|
63
|
+
output: {
|
|
64
|
+
path: outputPath,
|
|
65
|
+
filename: `js/[name].${hash ? '[contenthash].' : ''}js`,
|
|
66
|
+
publicPath,
|
|
55
67
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
module: {
|
|
69
|
+
rules: (0, loaders_1.default)({
|
|
70
|
+
isProd: this.isProd,
|
|
71
|
+
...this.opts,
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
plugins: (0, plugins_1.default)({
|
|
75
|
+
isProd: this.isProd,
|
|
76
|
+
analyzer,
|
|
77
|
+
...this.opts,
|
|
78
|
+
}),
|
|
79
|
+
resolve: {
|
|
80
|
+
extensions: this.extensions,
|
|
81
|
+
alias,
|
|
82
|
+
fallback: {
|
|
83
|
+
fs: false,
|
|
84
|
+
path: false,
|
|
85
|
+
events: false,
|
|
86
|
+
os: require.resolve('os-browserify/browser'),
|
|
87
|
+
crypto: require.resolve('crypto-browserify'),
|
|
88
|
+
stream: require.resolve('stream-browserify'),
|
|
89
|
+
buffer: require.resolve('buffer/'),
|
|
90
|
+
string_decoder: require.resolve('string_decoder/'),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
performance: {
|
|
94
|
+
hints: false,
|
|
95
|
+
},
|
|
96
|
+
cache: this.cache,
|
|
97
|
+
stats: {
|
|
98
|
+
cachedModules: false,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
return webpackBaseConf;
|
|
102
|
+
}
|
|
103
|
+
get isProd() {
|
|
104
|
+
return this.env === 'production';
|
|
105
|
+
}
|
|
68
106
|
}
|
|
69
|
-
exports.default =
|
|
107
|
+
exports.default = WebpackConfig;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../../utils");
|
|
4
|
+
class BabelLoader {
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.BABEL_LOADER = (0, utils_1.getResolvePath)('babel-loader');
|
|
7
|
+
this.opts = opts;
|
|
8
|
+
}
|
|
9
|
+
get config() {
|
|
10
|
+
return {
|
|
11
|
+
loader: this.BABEL_LOADER,
|
|
12
|
+
options: {
|
|
13
|
+
presets: [
|
|
14
|
+
[
|
|
15
|
+
(0, utils_1.getResolvePath)('babel-preset-ko-app'),
|
|
16
|
+
{
|
|
17
|
+
useAbsoluteRuntime: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
],
|
|
21
|
+
plugins: this.plugins,
|
|
22
|
+
babelrc: false,
|
|
23
|
+
configFile: false,
|
|
24
|
+
cacheIdentifier: this.cacheIdentifier,
|
|
25
|
+
cacheDirectory: !this.speedUp,
|
|
26
|
+
cacheCompression: false,
|
|
27
|
+
compact: this.opts.isProd,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
get treasurePluginConfig() {
|
|
32
|
+
const babelPluginTreasurePath = (0, utils_1.getResolvePath)('babel-plugin-treasure');
|
|
33
|
+
return [
|
|
34
|
+
[
|
|
35
|
+
babelPluginTreasurePath,
|
|
36
|
+
{
|
|
37
|
+
libraryName: 'antd',
|
|
38
|
+
libraryDirectory: 'lib',
|
|
39
|
+
style: 'css',
|
|
40
|
+
},
|
|
41
|
+
'antd',
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
babelPluginTreasurePath,
|
|
45
|
+
{
|
|
46
|
+
libraryName: 'dt-react-component',
|
|
47
|
+
libraryDirectory: '/src/components/',
|
|
48
|
+
camel2DashComponentName: 'lower',
|
|
49
|
+
},
|
|
50
|
+
'drc',
|
|
51
|
+
],
|
|
52
|
+
//TODO: check lodash tree shaking in webpack 5
|
|
53
|
+
// [
|
|
54
|
+
// babelPluginTreasurePath,
|
|
55
|
+
// {
|
|
56
|
+
// libraryName: 'lodash',
|
|
57
|
+
// libraryDirectory: '/',
|
|
58
|
+
// camel2DashComponentName: false,
|
|
59
|
+
// },
|
|
60
|
+
// 'lodash',
|
|
61
|
+
// ],
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
get plugins() {
|
|
65
|
+
return [...this.treasurePluginConfig].filter(Boolean);
|
|
66
|
+
}
|
|
67
|
+
get cacheIdentifier() {
|
|
68
|
+
return (0, utils_1.getCacheIdentifier)(this.opts.isProd ? 'production' : '', [
|
|
69
|
+
'ko',
|
|
70
|
+
'babel-preset-ko-app',
|
|
71
|
+
'babel-plugin-treasure',
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = BabelLoader;
|
|
@@ -6,5 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const style_1 = __importDefault(require("./style"));
|
|
7
7
|
const asset_1 = __importDefault(require("./asset"));
|
|
8
8
|
const script_1 = __importDefault(require("./script"));
|
|
9
|
-
const loaders =
|
|
9
|
+
const loaders = (opts) => {
|
|
10
|
+
const scripts = new script_1.default(opts);
|
|
11
|
+
const style = new style_1.default(opts);
|
|
12
|
+
return [...asset_1.default, ...style.config, ...scripts.config];
|
|
13
|
+
};
|
|
10
14
|
exports.default = loaders;
|
|
@@ -3,64 +3,58 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
test: /\.(t|j)sx?$/,
|
|
21
|
-
include: (input) => {
|
|
22
|
-
// internal modules dt-common compatible
|
|
23
|
-
if (input.includes('node_modules/dt-common/src/')) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
else if (input.includes('node_modules')) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
use: [
|
|
6
|
+
const babel_1 = __importDefault(require("./babel"));
|
|
7
|
+
class Script {
|
|
8
|
+
constructor(opts) {
|
|
9
|
+
this.THREAD_LOADER = require.resolve('thread-loader');
|
|
10
|
+
this.WORKER_LOADER = require.resolve('worker-loader');
|
|
11
|
+
this.ESBUILD_LOADER = require.resolve('esbuild-loader');
|
|
12
|
+
this.opts = opts;
|
|
13
|
+
this.BABEL_LOADER = new babel_1.default(opts);
|
|
14
|
+
}
|
|
15
|
+
get config() {
|
|
16
|
+
const scriptLoader = [
|
|
34
17
|
{
|
|
35
|
-
|
|
18
|
+
test: /\.worker.[jt]s$/,
|
|
19
|
+
loader: this.WORKER_LOADER,
|
|
36
20
|
options: {
|
|
37
|
-
|
|
38
|
-
name: 'ko-js-pool',
|
|
21
|
+
inline: 'fallback',
|
|
39
22
|
},
|
|
40
23
|
},
|
|
41
24
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: [],
|
|
55
|
-
babelrc: false,
|
|
56
|
-
configFile: false,
|
|
57
|
-
cacheIdentifier: (0, getCacheIdentifier_1.default)(config_1.default.isProductionEnv ? 'production' : '', ['babel-preset-ko-app', 'react-dev-utils', 'ko']),
|
|
58
|
-
cacheDirectory: true,
|
|
59
|
-
cacheCompression: false,
|
|
60
|
-
compact: config_1.default.isProductionEnv,
|
|
25
|
+
test: /\.(t|j)sx?$/,
|
|
26
|
+
include: (input) => {
|
|
27
|
+
// internal modules dt-common compatible
|
|
28
|
+
if (input.includes('node_modules/dt-common/src/')) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
else if (input.includes('node_modules')) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
61
37
|
},
|
|
38
|
+
use: [
|
|
39
|
+
{
|
|
40
|
+
loader: this.THREAD_LOADER,
|
|
41
|
+
options: {
|
|
42
|
+
name: 'ko-js-pool',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
this.opts.experiment?.speedUp
|
|
46
|
+
? {
|
|
47
|
+
loader: this.ESBUILD_LOADER,
|
|
48
|
+
options: {
|
|
49
|
+
loader: 'tsx',
|
|
50
|
+
target: 'es2020',
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
: this.BABEL_LOADER.config,
|
|
54
|
+
].filter(Boolean),
|
|
62
55
|
},
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
];
|
|
57
|
+
return scriptLoader;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = Script;
|
|
@@ -3,68 +3,176 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 =
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
7
8
|
const mini_css_extract_plugin_1 = require("mini-css-extract-plugin");
|
|
8
9
|
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
postcssOptions: {
|
|
28
|
-
plugins: [(0, autoprefixer_1.default)()],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
const styleLoaders = [
|
|
33
|
-
{
|
|
34
|
-
test: /\.css$/,
|
|
35
|
-
use: [styleLoader, cssLoader, postcssLoader],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
test: /\.s[ac]ss$/,
|
|
39
|
-
use: [
|
|
40
|
-
styleLoader,
|
|
41
|
-
cssLoader,
|
|
42
|
-
postcssLoader,
|
|
10
|
+
const postCssUrl = require('postcss-url');
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
class Style {
|
|
13
|
+
constructor(opts) {
|
|
14
|
+
this.CSS_LOADER = (0, utils_1.getResolvePath)('css-loader');
|
|
15
|
+
this.SASS_LOADER = (0, utils_1.getResolvePath)('sass-loader');
|
|
16
|
+
this.LESS_LOADER = (0, utils_1.getResolvePath)('less-loader');
|
|
17
|
+
this.POSTCSS_LOADER = (0, utils_1.getResolvePath)('postcss-loader');
|
|
18
|
+
this.CSS_MODULE_FILE_SUFFIX_REGEX = /\.module.s[ac]ss$/;
|
|
19
|
+
this.opts = opts;
|
|
20
|
+
}
|
|
21
|
+
get config() {
|
|
22
|
+
const enableCssModule = this.opts?.experiment?.enableCssModule;
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
test: /\.css$/,
|
|
26
|
+
use: [this.styleLoader, this.cssLoader, this.postCSSLoader],
|
|
27
|
+
},
|
|
43
28
|
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
test: /\.s[ac]ss$/,
|
|
30
|
+
exclude: (input) => {
|
|
31
|
+
if (enableCssModule) {
|
|
32
|
+
return this.CSS_MODULE_FILE_SUFFIX_REGEX.test(input);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
47
37
|
},
|
|
38
|
+
use: [
|
|
39
|
+
this.styleLoader,
|
|
40
|
+
this.cssLoader,
|
|
41
|
+
this.postCSSLoader,
|
|
42
|
+
this.sassLoader,
|
|
43
|
+
],
|
|
48
44
|
},
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
test: /\.less$/,
|
|
53
|
-
exclude: [path_1.default.join(process.cwd(), 'node_modules/antd-v4')],
|
|
54
|
-
use: [
|
|
55
|
-
styleLoader,
|
|
56
|
-
cssLoader,
|
|
57
|
-
postcssLoader,
|
|
45
|
+
enableCssModule && this.sassCssModuleConfig,
|
|
58
46
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
test: /\.less$/,
|
|
48
|
+
exclude: [this.realAntdV4Path],
|
|
49
|
+
use: [
|
|
50
|
+
this.styleLoader,
|
|
51
|
+
this.cssLoader,
|
|
52
|
+
this.postCSSLoader,
|
|
53
|
+
this.lessLoader,
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
test: /\.less$/,
|
|
58
|
+
include: [this.realAntdV4Path],
|
|
59
|
+
use: [
|
|
60
|
+
this.styleLoader,
|
|
61
|
+
this.cssLoader,
|
|
62
|
+
this.postCSSLoader,
|
|
63
|
+
this.antdV4LessLoader,
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
get sassCssModuleConfig() {
|
|
69
|
+
return {
|
|
70
|
+
test: /\.module.s[ac]ss$/,
|
|
71
|
+
use: [
|
|
72
|
+
this.styleLoader,
|
|
73
|
+
{
|
|
74
|
+
loader: this.CSS_LOADER,
|
|
75
|
+
options: {
|
|
76
|
+
esModule: true,
|
|
77
|
+
modules: {
|
|
78
|
+
namedExport: true,
|
|
79
|
+
localIdentName: this.opts.isProd
|
|
80
|
+
? '[path][name]__[local]'
|
|
81
|
+
: '[local]_[hash:base64]',
|
|
82
|
+
},
|
|
63
83
|
},
|
|
64
|
-
sourceMap: true,
|
|
65
84
|
},
|
|
85
|
+
this.postCSSLoader,
|
|
86
|
+
this.sassLoader,
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//TODO: remove when upgrade to antd v4
|
|
91
|
+
get realAntdV4Path() {
|
|
92
|
+
const antdV4Path = (0, path_1.join)(this.opts.cwd, 'node_modules/antd-v4');
|
|
93
|
+
const ret = (0, fs_1.existsSync)(antdV4Path) ? (0, fs_1.realpathSync)(antdV4Path) : antdV4Path;
|
|
94
|
+
return ret;
|
|
95
|
+
}
|
|
96
|
+
get styleLoader() {
|
|
97
|
+
return {
|
|
98
|
+
loader: mini_css_extract_plugin_1.loader,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
get cssLoader() {
|
|
102
|
+
return {
|
|
103
|
+
loader: this.CSS_LOADER,
|
|
104
|
+
options: {
|
|
105
|
+
sourceMap: true,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
get sassLoader() {
|
|
110
|
+
return {
|
|
111
|
+
loader: this.SASS_LOADER,
|
|
112
|
+
options: {
|
|
113
|
+
sourceMap: true,
|
|
66
114
|
},
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
get lessLoader() {
|
|
118
|
+
const { lessOptions = {} } = this.opts;
|
|
119
|
+
return {
|
|
120
|
+
loader: this.LESS_LOADER,
|
|
121
|
+
options: {
|
|
122
|
+
sourceMap: true,
|
|
123
|
+
lessOptions,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
get antdV4LessLoader() {
|
|
128
|
+
const { antdV4LessOptions = {} } = this.opts;
|
|
129
|
+
return {
|
|
130
|
+
loader: this.LESS_LOADER,
|
|
131
|
+
options: {
|
|
132
|
+
sourceMap: true,
|
|
133
|
+
lessOptions: antdV4LessOptions,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
get postCSSLoader() {
|
|
138
|
+
return {
|
|
139
|
+
loader: this.POSTCSS_LOADER,
|
|
140
|
+
options: {
|
|
141
|
+
sourceMap: true,
|
|
142
|
+
postcssOptions: {
|
|
143
|
+
plugins: this.postCSSPlugins,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
get postCSSPlugins() {
|
|
149
|
+
const extraPostCSSPlugins = this.opts.extraPostCSSPlugins || [];
|
|
150
|
+
return [
|
|
151
|
+
(0, autoprefixer_1.default)(),
|
|
152
|
+
postCssUrl([
|
|
153
|
+
{
|
|
154
|
+
filter: '**/src/public/img/**/*',
|
|
155
|
+
url: (args) => {
|
|
156
|
+
const originUrl = args?.originUrl;
|
|
157
|
+
return originUrl
|
|
158
|
+
? (0, path_1.join)(this.opts.cwd, originUrl)
|
|
159
|
+
: args.absolutePath;
|
|
160
|
+
},
|
|
161
|
+
basePath: '/',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
filter: '**/src/public/font/**/*',
|
|
165
|
+
url: (args) => {
|
|
166
|
+
const originUrl = args?.originUrl;
|
|
167
|
+
return originUrl
|
|
168
|
+
? (0, path_1.join)(this.opts.cwd, originUrl)
|
|
169
|
+
: args.absolutePath;
|
|
170
|
+
},
|
|
171
|
+
basePath: '/',
|
|
172
|
+
},
|
|
173
|
+
]),
|
|
174
|
+
...extraPostCSSPlugins,
|
|
175
|
+
].filter(Boolean);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.default = Style;
|