@celljs/react 3.9.0 → 4.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/react",
3
- "version": "3.9.0",
3
+ "version": "4.1.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -20,8 +20,7 @@
20
20
  "lib",
21
21
  "esm",
22
22
  "src",
23
- "cell.yml",
24
- "cell-cdn.yml"
23
+ "cell.yml"
25
24
  ],
26
25
  "scripts": {
27
26
  "build": "tsc -b && bun ../../scripts/build-esm.ts",
@@ -30,116 +29,90 @@
30
29
  "watch": "tsc -b -w --preserveWatchOutput"
31
30
  },
32
31
  "dependencies": {
33
- "@celljs/cli-common": "3.9.0",
34
- "@celljs/core": "3.9.0",
35
- "@celljs/widget": "3.9.0",
32
+ "@celljs/core": "4.1.0",
33
+ "@celljs/widget": "4.1.0",
36
34
  "@types/react": "^18.0.17",
37
- "@types/react-dom": "^18.0.6",
38
- "@types/react-router-dom": "^5.3.3",
39
- "autoprefixer": "^10.4.20",
40
- "css-minimizer-webpack-plugin": "^7.0.0",
41
- "cssnano": "^7.0.6",
42
- "fs-extra": "^11.1.1",
43
- "less": "^4.1.1",
44
- "less-loader": "^9.0.0",
45
- "mini-css-extract-plugin": "^2.7.6",
46
- "postcss-loader": "^5.3.0",
47
35
  "react": "^18.2.0",
48
36
  "react-dom": "^18.2.0",
49
37
  "react-intl": "^6.0.5",
50
- "react-router-dom": "^6.3.0",
51
- "sass": "^1.32.8",
52
- "sass-loader": "^11.1.1",
53
- "style-loader": "^3.3.1",
54
- "stylus": "^0.54.8",
55
- "stylus-loader": "^6.0.0",
56
- "tslib": "^2.8.0"
57
- },
58
- "devDependencies": {
59
- "@celljs/cli-service": "3.9.0"
38
+ "react-router-dom": "^6.3.0"
60
39
  },
61
40
  "publishConfig": {
62
41
  "access": "public"
63
42
  },
64
43
  "exports": {
65
44
  ".": {
66
- "webpack": "./lib/browser/index.js",
67
45
  "import": "./esm/browser/index.js",
68
46
  "default": "./lib/browser/index.js"
69
47
  },
70
48
  "./package.json": "./package.json",
71
- "./lib/hooks/*.js": "./lib/hooks/*.js",
72
- "./lib/hooks/*": "./lib/hooks/*.js",
73
49
  "./lib/browser": {
74
- "webpack": "./lib/browser/index.js",
75
50
  "import": "./esm/browser/index.js",
76
51
  "default": "./lib/browser/index.js"
77
52
  },
78
53
  "./lib/browser/annotation": {
79
- "webpack": "./lib/browser/annotation/index.js",
80
54
  "import": "./esm/browser/annotation/index.js",
81
55
  "default": "./lib/browser/annotation/index.js"
82
56
  },
83
57
  "./lib/browser/app": {
84
- "webpack": "./lib/browser/app/index.js",
85
58
  "import": "./esm/browser/app/index.js",
86
59
  "default": "./lib/browser/app/index.js"
87
60
  },
88
61
  "./lib/browser/context": {
89
- "webpack": "./lib/browser/context/index.js",
90
62
  "import": "./esm/browser/context/index.js",
91
63
  "default": "./lib/browser/context/index.js"
92
64
  },
93
65
  "./lib/browser/icon": {
94
- "webpack": "./lib/browser/icon/index.js",
95
66
  "import": "./esm/browser/icon/index.js",
96
67
  "default": "./lib/browser/icon/index.js"
97
68
  },
98
69
  "./lib/browser/layout": {
99
- "webpack": "./lib/browser/layout/index.js",
100
70
  "import": "./esm/browser/layout/index.js",
101
71
  "default": "./lib/browser/layout/index.js"
102
72
  },
103
73
  "./lib/browser/locale": {
104
- "webpack": "./lib/browser/locale/index.js",
105
74
  "import": "./esm/browser/locale/index.js",
106
75
  "default": "./lib/browser/locale/index.js"
107
76
  },
108
77
  "./lib/browser/resolver": {
109
- "webpack": "./lib/browser/resolver/index.js",
110
78
  "import": "./esm/browser/resolver/index.js",
111
79
  "default": "./lib/browser/resolver/index.js"
112
80
  },
113
81
  "./lib/browser/router": {
114
- "webpack": "./lib/browser/router/index.js",
115
82
  "import": "./esm/browser/router/index.js",
116
83
  "default": "./lib/browser/router/index.js"
117
84
  },
118
85
  "./lib/browser/shell": {
119
- "webpack": "./lib/browser/shell/index.js",
120
86
  "import": "./esm/browser/shell/index.js",
121
87
  "default": "./lib/browser/shell/index.js"
122
88
  },
123
89
  "./lib/browser/slot": {
124
- "webpack": "./lib/browser/slot/index.js",
125
90
  "import": "./esm/browser/slot/index.js",
126
91
  "default": "./lib/browser/slot/index.js"
127
92
  },
128
93
  "./lib/browser/widget": {
129
- "webpack": "./lib/browser/widget/index.js",
130
94
  "import": "./esm/browser/widget/index.js",
131
95
  "default": "./lib/browser/widget/index.js"
132
96
  },
133
97
  "./lib/*.js": {
134
- "webpack": "./lib/*.js",
135
98
  "import": "./esm/*.js",
136
99
  "default": "./lib/*.js"
137
100
  },
138
101
  "./lib/*": {
139
- "webpack": "./lib/*.js",
140
102
  "import": "./esm/*.js",
141
103
  "default": "./lib/*.js"
142
104
  },
143
105
  "./*": "./*"
106
+ },
107
+ "cell": {
108
+ "modules": {
109
+ "frontend": [
110
+ "lib/browser/module"
111
+ ]
112
+ }
113
+ },
114
+ "devDependencies": {
115
+ "@types/react-dom": "^18.0.6",
116
+ "@types/react-router-dom": "^5.3.3"
144
117
  }
145
118
  }
package/cell-cdn.yml DELETED
@@ -1,11 +0,0 @@
1
- frontend:
2
- cell:
3
- webpack:
4
- config:
5
- externals:
6
- react: React
7
- react-dom: ReactDOM
8
- htmlWebpackTagsPlugin:
9
- react: "https://cdn.jsdelivr.net/npm/react@^18.2.0/umd/react.${cliContext.dev ? 'development' : 'production.min'}.js"
10
- react-dom: "https://cdn.jsdelivr.net/npm/react-dom@^18.2.0/umd/react-dom.${cliContext.dev ? 'development' : 'production.min'}.js"
11
-
@@ -1,4 +0,0 @@
1
- import { WebpackContext } from '@celljs/cli-service/lib/context/context-protocol';
2
- export default _default;
3
- declare function _default(context: WebpackContext): Promise<void>;
4
- //# sourceMappingURL=webpack.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/hooks/webpack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAwB,MAAM,kDAAkD,CAAC;;0BAqBlF,OAAO,EAAE,cAAc"}
@@ -1,203 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const fs = __importStar(require("fs-extra"));
37
- const path = __importStar(require("path"));
38
- const context_protocol_1 = require("@celljs/cli-service/lib/context/context-protocol");
39
- const config_util_1 = require("@celljs/cli-common/lib/utils/config-util");
40
- const findExisting = (context, files) => {
41
- for (const file of files) {
42
- if (fs.existsSync(path.join(context, file))) {
43
- return file;
44
- }
45
- }
46
- };
47
- exports.default = async (context) => {
48
- var _a;
49
- var _b;
50
- const { configurations, cfg, dev } = context;
51
- const webpackConfig = context_protocol_1.ConfigurationContext.getFrontendConfiguration(configurations);
52
- if (webpackConfig) {
53
- const appRootDir = process.cwd();
54
- const shadowMode = false;
55
- const rootReactOptions = (_b = (_a = config_util_1.ConfigUtil.getFrontendCellConfig(cfg)) === null || _a === void 0 ? void 0 : _a.react) !== null && _b !== void 0 ? _b : {};
56
- const defaultSassLoaderOptions = {
57
- implementation: require('sass')
58
- };
59
- const css = rootReactOptions.css || {};
60
- const { extract = !dev, sourceMap = false, loaderOptions = {} } = css;
61
- let { requireModuleExtension } = css;
62
- if (typeof requireModuleExtension === 'undefined') {
63
- if (loaderOptions.css && loaderOptions.css.modules) {
64
- throw new Error('`css.requireModuleExtension` is required when custom css modules options provided');
65
- }
66
- requireModuleExtension = true;
67
- }
68
- const { filenameHashing = true, productionSourceMap = true } = rootReactOptions;
69
- const shouldExtract = extract !== false && !shadowMode;
70
- const filename = `css/[name]${filenameHashing ? '.[contenthash:8]' : ''}.css`;
71
- const cssPublicPath = '../';
72
- const extractOptions = Object.assign({
73
- filename,
74
- chunkFilename: filename,
75
- }, extract && typeof extract === 'object' ? extract : {});
76
- const hasPostCSSConfig = !!(loaderOptions.postcss ||
77
- findExisting(appRootDir, [
78
- '.postcssrc',
79
- '.postcssrc.js',
80
- 'postcss.config.js',
81
- '.postcssrc.yaml',
82
- '.postcssrc.json',
83
- ]));
84
- if (!hasPostCSSConfig) {
85
- loaderOptions.postcss = {
86
- postcssOptions: {
87
- plugins: [require('autoprefixer')],
88
- }
89
- };
90
- }
91
- // if building for production but not extracting CSS, we need to minimize
92
- // the embbeded inline CSS as they will not be going through the optimizing
93
- // plugin.
94
- const needInlineMinification = !dev && !shouldExtract;
95
- const cssnanoOptions = {
96
- preset: [
97
- 'default',
98
- {
99
- mergeLonghand: false,
100
- cssDeclarationSorter: false,
101
- },
102
- ],
103
- };
104
- if (productionSourceMap && sourceMap) {
105
- // @ts-ignore
106
- cssnanoOptions.map = { inline: false };
107
- }
108
- // @ts-ignore
109
- function createCSSRule(lang, test, loader, options = {}) {
110
- const baseRule = webpackConfig.module.rule(lang).test(test);
111
- // rules for *.module.* files
112
- const extModulesRule = baseRule
113
- .oneOf('normal-modules')
114
- .test(/\.module\.\w+$/);
115
- applyLoaders(extModulesRule, true);
116
- // rules for normal CSS imports
117
- const normalRule = baseRule.oneOf('normal');
118
- applyLoaders(normalRule, !requireModuleExtension);
119
- function applyLoaders(rule, isCssModule) {
120
- if (shouldExtract) {
121
- rule.use('extract-css-loader')
122
- .loader(require('mini-css-extract-plugin').loader)
123
- .options({
124
- publicPath: cssPublicPath,
125
- });
126
- }
127
- else {
128
- rule.use('style-loader')
129
- .loader(require.resolve('style-loader'))
130
- .options({
131
- injectType: 'singletonStyleTag'
132
- });
133
- }
134
- const cssLoaderOptions = Object.assign({
135
- sourceMap,
136
- importLoaders: 1 + // stylePostLoader injected by vue-loader
137
- 1 + // postcss-loader
138
- (needInlineMinification ? 1 : 0),
139
- }, loaderOptions.css);
140
- if (isCssModule) {
141
- cssLoaderOptions.modules = {
142
- localIdentName: '[name]_[local]_[hash:base64:5]',
143
- ...cssLoaderOptions.modules,
144
- };
145
- }
146
- else {
147
- delete cssLoaderOptions.modules;
148
- }
149
- rule.use('css-loader')
150
- .loader(require.resolve('css-loader'))
151
- .options(cssLoaderOptions);
152
- if (needInlineMinification) {
153
- rule.use('cssnano')
154
- .loader(require.resolve('postcss-loader'))
155
- .options({
156
- sourceMap,
157
- plugins: [require('cssnano')(cssnanoOptions)],
158
- });
159
- }
160
- rule.use('postcss-loader')
161
- .loader(require.resolve('postcss-loader'))
162
- .options(Object.assign({ sourceMap }, loaderOptions.postcss));
163
- if (loader) {
164
- let resolvedLoader;
165
- try {
166
- resolvedLoader = require.resolve(loader);
167
- }
168
- catch (error) {
169
- resolvedLoader = loader;
170
- }
171
- rule.use(loader)
172
- .loader(resolvedLoader)
173
- .options(Object.assign({ sourceMap }, options));
174
- }
175
- }
176
- }
177
- createCSSRule('css', /\.css$/);
178
- createCSSRule('postcss', /\.p(ost)?css$/);
179
- createCSSRule('scss', /\.scss$/, 'sass-loader', Object.assign({}, defaultSassLoaderOptions, loaderOptions.scss || loaderOptions.sass));
180
- createCSSRule('sass', /\.sass$/, 'sass-loader', Object.assign({}, defaultSassLoaderOptions, loaderOptions.sass, {
181
- sassOptions: Object.assign({}, loaderOptions.sass &&
182
- loaderOptions.sass.sassOptions, {
183
- indentedSyntax: true,
184
- }),
185
- }));
186
- createCSSRule('less', /\.less$/, 'less-loader', loaderOptions.less);
187
- createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader', Object.assign({
188
- preferPathResolver: 'webpack',
189
- }, loaderOptions.stylus));
190
- // inject CSS extraction plugin
191
- if (shouldExtract) {
192
- webpackConfig
193
- .plugin('extract-css')
194
- .use(require('mini-css-extract-plugin'), [extractOptions]);
195
- // minify extracted CSS
196
- webpackConfig
197
- .optimization
198
- .minimizer('optimize-css')
199
- .use(require('css-minimizer-webpack-plugin'));
200
- }
201
- }
202
- };
203
- //# sourceMappingURL=webpack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../src/hooks/webpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,qCAAiB;AAC/B,MAAY,IAAI,iCAAa;AAC7B,uFAAwG;AACxG,0EAAsE;AAYtE,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE;IACtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;AACL,CAAC,CAAC;kBAEa,KAAK,EAAE,OAAuB,EAAE,EAAE;;;IAC7C,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,EAAE,GA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AAC,IAAI,EAClB;YACI,WAAW,EAAE,MAAM,CAAC,MAAM,CACtB,EAAE,EACF,aAAa,CAAC,IAAI;gBAClB,aAAa,CAAC,IAAI,CAAC,WAAW,EAC9B;gBACI,cAAc,EAAE,IAAI;aACvB,CACJ;SACJ,CACJ,CACJ,CAAC;QACF,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QACpE,aAAa,CACT,QAAQ,EACR,cAAc,EACd,eAAe,EACf,MAAM,CAAC,MAAM,CACT;YACI,kBAAkB,EAAE,SAAS;SAChC,EACD,aAAa,CAAC,MAAM,CACvB,CACJ,CAAC;QAEF,+BAA+B;QAC/B,IAAI,aAAa,EAAE,CAAC;YAChB,aAAa;iBACR,MAAM,CAAC,aAAa,CAAC;iBACrB,GAAG,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE/D,uBAAuB;YACvB,aAAa;iBACJ,YAAY;iBACR,SAAS,CAAC,cAAc,CAAC;iBACrB,GAAG,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -1,244 +0,0 @@
1
- import * as fs from 'fs-extra';
2
- import * as path from 'path';
3
- import { WebpackContext, ConfigurationContext } from '@celljs/cli-service/lib/context/context-protocol';
4
- import { ConfigUtil } from '@celljs/cli-common/lib/utils/config-util';
5
- /* eslint-disable @typescript-eslint/ban-ts-comment */
6
-
7
- interface LoaderOptions {
8
- css: any,
9
- scss: any,
10
- sass: any,
11
- less: any,
12
- stylus: any,
13
- postcss: any,
14
- }
15
-
16
- const findExisting = (context: string, files: string[]) => {
17
- for (const file of files) {
18
- if (fs.existsSync(path.join(context, file))) {
19
- return file;
20
- }
21
- }
22
- };
23
-
24
- export default async (context: WebpackContext) => {
25
- const { configurations, cfg, dev } = context;
26
- const webpackConfig = ConfigurationContext.getFrontendConfiguration(
27
- configurations
28
- );
29
- if (webpackConfig) {
30
- const appRootDir = process.cwd();
31
- const shadowMode = false;
32
- const rootReactOptions = ConfigUtil.getFrontendCellConfig(cfg)?.react ?? {};
33
- const defaultSassLoaderOptions = {
34
- implementation: require('sass')
35
- };
36
- const css = rootReactOptions.css || {};
37
- const { extract = !dev, sourceMap = false, loaderOptions = {} as LoaderOptions } = css;
38
-
39
- let { requireModuleExtension } = css;
40
- if (typeof requireModuleExtension === 'undefined') {
41
- if (loaderOptions.css && loaderOptions.css.modules) {
42
- throw new Error(
43
- '`css.requireModuleExtension` is required when custom css modules options provided'
44
- );
45
- }
46
- requireModuleExtension = true;
47
- }
48
-
49
- const { filenameHashing = true, productionSourceMap = true } = rootReactOptions;
50
- const shouldExtract = extract !== false && !shadowMode;
51
- const filename = `css/[name]${filenameHashing ? '.[contenthash:8]' : ''}.css`;
52
- const cssPublicPath = '../';
53
-
54
- const extractOptions = Object.assign(
55
- {
56
- filename,
57
- chunkFilename: filename,
58
- },
59
- extract && typeof extract === 'object' ? extract : {}
60
- );
61
-
62
- const hasPostCSSConfig = !!(
63
- loaderOptions.postcss ||
64
- findExisting(appRootDir, [
65
- '.postcssrc',
66
- '.postcssrc.js',
67
- 'postcss.config.js',
68
- '.postcssrc.yaml',
69
- '.postcssrc.json',
70
- ])
71
- );
72
-
73
- if (!hasPostCSSConfig) {
74
- loaderOptions.postcss = {
75
- postcssOptions: {
76
- plugins: [require('autoprefixer')],
77
- }
78
- };
79
- }
80
-
81
- // if building for production but not extracting CSS, we need to minimize
82
- // the embbeded inline CSS as they will not be going through the optimizing
83
- // plugin.
84
- const needInlineMinification = !dev && !shouldExtract;
85
-
86
- const cssnanoOptions = {
87
- preset: [
88
- 'default',
89
- {
90
- mergeLonghand: false,
91
- cssDeclarationSorter: false,
92
- },
93
- ],
94
- };
95
- if (productionSourceMap && sourceMap) {
96
- // @ts-ignore
97
- cssnanoOptions.map = { inline: false };
98
- }
99
-
100
- // @ts-ignore
101
- function createCSSRule(lang: string,
102
- test: RegExp,
103
- loader?: string,
104
- options = {}) {
105
- const baseRule = webpackConfig!.module.rule(lang).test(test);
106
-
107
- // rules for *.module.* files
108
- const extModulesRule = baseRule
109
- .oneOf('normal-modules')
110
- .test(/\.module\.\w+$/);
111
- applyLoaders(extModulesRule, true);
112
-
113
- // rules for normal CSS imports
114
- const normalRule = baseRule.oneOf('normal');
115
- applyLoaders(normalRule, !requireModuleExtension);
116
-
117
- function applyLoaders(rule: any, isCssModule: boolean) {
118
- if (shouldExtract) {
119
- rule.use('extract-css-loader')
120
- .loader(require('mini-css-extract-plugin').loader)
121
- .options({
122
- publicPath: cssPublicPath,
123
- });
124
- } else {
125
- rule.use('style-loader')
126
- .loader(require.resolve('style-loader'))
127
- .options({
128
- injectType: 'singletonStyleTag'
129
- });
130
- }
131
-
132
- const cssLoaderOptions = Object.assign(
133
- {
134
- sourceMap,
135
- importLoaders:
136
- 1 + // stylePostLoader injected by vue-loader
137
- 1 + // postcss-loader
138
- (needInlineMinification ? 1 : 0),
139
- },
140
- loaderOptions.css
141
- );
142
-
143
- if (isCssModule) {
144
- cssLoaderOptions.modules = {
145
- localIdentName: '[name]_[local]_[hash:base64:5]',
146
- ...cssLoaderOptions.modules,
147
- };
148
- } else {
149
- delete cssLoaderOptions.modules;
150
- }
151
-
152
- rule.use('css-loader')
153
- .loader(require.resolve('css-loader'))
154
- .options(cssLoaderOptions);
155
-
156
- if (needInlineMinification) {
157
- rule.use('cssnano')
158
- .loader(require.resolve('postcss-loader'))
159
- .options({
160
- sourceMap,
161
- plugins: [require('cssnano')(cssnanoOptions)],
162
- });
163
- }
164
-
165
- rule.use('postcss-loader')
166
- .loader(require.resolve('postcss-loader'))
167
- .options(
168
- Object.assign({ sourceMap }, loaderOptions.postcss)
169
- );
170
-
171
- if (loader) {
172
- let resolvedLoader;
173
- try {
174
- resolvedLoader = require.resolve(loader);
175
- } catch (error) {
176
- resolvedLoader = loader;
177
- }
178
-
179
- rule.use(loader)
180
- .loader(resolvedLoader)
181
- .options(Object.assign({ sourceMap }, options));
182
- }
183
- }
184
- }
185
-
186
- createCSSRule('css', /\.css$/);
187
- createCSSRule('postcss', /\.p(ost)?css$/);
188
- createCSSRule(
189
- 'scss',
190
- /\.scss$/,
191
- 'sass-loader',
192
- Object.assign(
193
- {},
194
- defaultSassLoaderOptions,
195
- loaderOptions.scss || loaderOptions.sass
196
- )
197
- );
198
- createCSSRule(
199
- 'sass',
200
- /\.sass$/,
201
- 'sass-loader',
202
- Object.assign(
203
- {},
204
- defaultSassLoaderOptions,
205
- loaderOptions.sass,
206
- {
207
- sassOptions: Object.assign(
208
- {},
209
- loaderOptions.sass &&
210
- loaderOptions.sass.sassOptions,
211
- {
212
- indentedSyntax: true,
213
- }
214
- ),
215
- }
216
- )
217
- );
218
- createCSSRule('less', /\.less$/, 'less-loader', loaderOptions.less);
219
- createCSSRule(
220
- 'stylus',
221
- /\.styl(us)?$/,
222
- 'stylus-loader',
223
- Object.assign(
224
- {
225
- preferPathResolver: 'webpack',
226
- },
227
- loaderOptions.stylus
228
- )
229
- );
230
-
231
- // inject CSS extraction plugin
232
- if (shouldExtract) {
233
- webpackConfig
234
- .plugin('extract-css')
235
- .use(require('mini-css-extract-plugin'), [extractOptions]);
236
-
237
- // minify extracted CSS
238
- webpackConfig
239
- .optimization
240
- .minimizer('optimize-css')
241
- .use(require('css-minimizer-webpack-plugin'));
242
- }
243
- }
244
- };