@ecoding/base.build 0.0.11 → 0.0.12
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.
|
@@ -7,7 +7,11 @@ const loaders = [
|
|
|
7
7
|
{
|
|
8
8
|
loader: "css-loader",
|
|
9
9
|
options: {
|
|
10
|
-
modules:
|
|
10
|
+
modules: { // enable CSS modules for all files matching /\.module\.\w+$/i.test(filename) and /\.icss\.\w+$/i.test(filename) regexp.
|
|
11
|
+
auto: true,
|
|
12
|
+
mode: "local",
|
|
13
|
+
localIdentName: '[name]-[local]--[hash:base64:5]',
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
{
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const loaders = [
|
|
2
|
+
{
|
|
3
|
+
loader: "css-loader",
|
|
4
|
+
options: {
|
|
5
|
+
modules: { // enable CSS modules for all files matching /\.module\.\w+$/i.test(filename) and /\.icss\.\w+$/i.test(filename) regexp.
|
|
6
|
+
auto: true,
|
|
7
|
+
mode: "local",
|
|
8
|
+
localIdentName: '[name]-[local]--[hash:base64:5]',
|
|
9
|
+
exportOnlyLocals: true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
loader: "postcss-loader",
|
|
15
|
+
options: {
|
|
16
|
+
postcssOptions: {
|
|
17
|
+
plugins: {
|
|
18
|
+
autoprefixer: {
|
|
19
|
+
overrideBrowserslist: ["IE 10", "iOS >=6", "Android >=4"],
|
|
20
|
+
remove: false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
].filter(Boolean);
|
|
27
|
+
const getLessRule = () => {
|
|
28
|
+
return {
|
|
29
|
+
test: /\.less$/,
|
|
30
|
+
use: [
|
|
31
|
+
...loaders,
|
|
32
|
+
{
|
|
33
|
+
loader: "less-loader",
|
|
34
|
+
options: {
|
|
35
|
+
lessOptions: {
|
|
36
|
+
javascriptEnabled: true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getCssRule = () => {
|
|
45
|
+
return {
|
|
46
|
+
test: /\.css$/,
|
|
47
|
+
use: [...loaders]
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
getCssRule,
|
|
53
|
+
getLessRule
|
|
54
|
+
};
|
package/libs/module/ssr.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
const getTsRule = require("./ts-loader");
|
|
2
1
|
const getImgRule = require("./img-loader");
|
|
3
2
|
const getSvgRule = require("./svg-loader");
|
|
4
3
|
const getFontRule = require("./font-loader");
|
|
4
|
+
const { getLessRule, getCssRule } = require("./css-loader/ssr");
|
|
5
|
+
const { rootPath } = require("../z-helpers/paths");
|
|
5
6
|
|
|
6
7
|
const getModule = () => {
|
|
7
|
-
const tsRule = getTsRule();
|
|
8
8
|
const imgRule = getImgRule();
|
|
9
9
|
const svgRule = getSvgRule();
|
|
10
10
|
const fontRule = getFontRule();
|
|
11
|
+
const cssRule = getCssRule();
|
|
12
|
+
const lessRule = getLessRule();
|
|
11
13
|
|
|
12
14
|
return {
|
|
13
15
|
// noParse:/test.js$/, 不编译正则匹配上的文件
|
|
14
16
|
rules: [
|
|
15
|
-
tsRule,
|
|
16
17
|
{
|
|
17
|
-
test: /\.(
|
|
18
|
-
|
|
18
|
+
test: /\.(tsx?|jsx?)$/, // js ts 都走一遍 ts 进行编译
|
|
19
|
+
use: "ts-loader",
|
|
20
|
+
exclude: /node_modules/,
|
|
21
|
+
include: [rootPath("src"), /\/node_modules\/@ecoding.*/],
|
|
19
22
|
},
|
|
23
|
+
lessRule,
|
|
24
|
+
cssRule,
|
|
20
25
|
imgRule,
|
|
21
26
|
svgRule,
|
|
22
27
|
fontRule
|
package/libs/webpack.ssr.js
CHANGED
|
@@ -9,6 +9,7 @@ const { getResolve, getResolveLoader } = require("./resolve");
|
|
|
9
9
|
const getPlugins = require("./plugins/ssr");
|
|
10
10
|
const getExternals = require("./externals/ssr");
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
14
15
|
* @param {*} cmdOpts : build时 { WEBPACK_BUNDLE: true, WEBPACK_BUILD: true } | 本地开发dev时 { WEBPACK_SERVE: true }
|
|
@@ -55,7 +56,6 @@ const getWebpackConfig = (env) => {
|
|
|
55
56
|
|
|
56
57
|
// 配置externals
|
|
57
58
|
const externals = getExternals();
|
|
58
|
-
|
|
59
59
|
const config = {
|
|
60
60
|
target: "node",
|
|
61
61
|
mode,
|
|
@@ -68,8 +68,10 @@ const getWebpackConfig = (env) => {
|
|
|
68
68
|
resolve,
|
|
69
69
|
plugins,
|
|
70
70
|
externalsPresets: { node: true }, // 不打包 node 模块,什么 fs path 那些
|
|
71
|
-
externals
|
|
71
|
+
externals, // 不打包 node_modules 内的模块,什么 express react react-dom 那些
|
|
72
72
|
};
|
|
73
|
+
// tsx 配置
|
|
74
|
+
// 服务器端代码构建
|
|
73
75
|
return config;
|
|
74
76
|
};
|
|
75
77
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/base.build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "tpl building",
|
|
5
5
|
"author": "cxc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "247243b7d008258a17064708b1abb15dcd361830"
|
|
57
57
|
}
|