chisel-scripts 1.0.0-alpha.5 → 1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## 1.0.0 (2021-12-17)
6
+
7
+ - Rewrite with Webpack (#509) ([14fa2d0](https://github.com/xfiveco/generator-chisel/commit/14fa2d0)), closes [#509](https://github.com/xfiveco/generator-chisel/issues/509)
8
+
9
+ ## 1.0.0-alpha.8 (2021-12-16)
10
+
11
+ ## 1.0.0-alpha.7 (2020-09-21)
12
+
13
+ - Add WP dev server test with puppeteer ([dbc0f1d](https://github.com/xfiveco/generator-chisel/commit/dbc0f1d))
14
+
15
+ ## 1.0.0-alpha.6 (2020-08-06)
16
+
17
+ - Update CSS bundling: use custom loader instead of importer, make fibers optional ([829dc26](https://github.com/xfiveco/generator-chisel/commit/829dc26))
18
+
5
19
  ## 1.0.0-alpha.5 (2020-08-04)
6
20
 
7
21
  - Add frontend generator and commands tests ([c32fa26](https://github.com/xfiveco/generator-chisel/commit/c32fa26))
package/lib/Service.js CHANGED
@@ -182,7 +182,17 @@ module.exports = class Service {
182
182
 
183
183
  const commanderArgs = [...(name ? [name] : []), ...args];
184
184
 
185
- return this.program.parseAsync(commanderArgs, { from: 'user' });
185
+ await this.program.parseAsync(commanderArgs, { from: 'user' });
186
+ if (this.program._actionResults) {
187
+ const results = await Promise.all(this.program._actionResults);
188
+ if (results.length === 1) {
189
+ return results[0];
190
+ }
191
+
192
+ return results;
193
+ }
194
+
195
+ return undefined;
186
196
  }
187
197
 
188
198
  async resolveChainableWebpackConfig() {
package/lib/config/css.js CHANGED
@@ -1,6 +1,5 @@
1
1
  module.exports = (api, options) => {
2
2
  api.chainWebpack((webpackConfig) => {
3
- const globby = require('globby');
4
3
  const path = require('path');
5
4
 
6
5
  const isProd = process.env.NODE_ENV === 'production';
@@ -11,21 +10,7 @@ module.exports = (api, options) => {
11
10
  sassOptions: {
12
11
  indentedSyntax: false,
13
12
  includePaths: [api.resolve('node_modules')], // TODO: don't use?
14
- outputStyle: 'expanded', // TODO: test postcss and add minifier
15
- importer(url, prev, done) {
16
- (async () => {
17
- if (globby.hasMagic(url)) {
18
- const files = (
19
- await globby(url, { cwd: path.dirname(prev) })
20
- ).sort();
21
- done({
22
- contents: files.map((file) => `@import '${file}';`).join('\n'),
23
- });
24
- } else {
25
- done(null);
26
- }
27
- })();
28
- },
13
+ outputStyle: 'expanded',
29
14
  },
30
15
  };
31
16
 
@@ -50,6 +35,9 @@ module.exports = (api, options) => {
50
35
  path.join(options.source.base, options.source.assets),
51
36
  );
52
37
 
38
+ // Note: thread loader cannot be used right now
39
+ // https://github.com/webpack-contrib/thread-loader/issues/79
40
+
53
41
  const createCssLoader = (rule, test) => {
54
42
  // prettier-ignore
55
43
  return webpackConfig.module.rule(rule).test(test)
@@ -78,6 +66,9 @@ module.exports = (api, options) => {
78
66
  .loader(require.resolve('sass-loader'))
79
67
  .options(sassLoaderOptions)
80
68
  .end()
69
+ .use('sass-glob-loader')
70
+ .loader(require.resolve('../webpack-loaders/sass-glob-loader.js'))
71
+ .end();
81
72
 
82
73
  webpackConfig
83
74
  .plugin('extract-css')
@@ -0,0 +1,41 @@
1
+ // Based on https://github.com/mikevercoelen/gulp-sass-glob/blob/255ee047789e69c82d5e3fc87452360ef8c56f41/src/index.js
2
+
3
+ // we initially used custom dart-sass importer instead of this but there
4
+ // is noticeable performance difference
5
+
6
+ const path = require('path');
7
+ const globby = require('globby');
8
+
9
+ const IMPORT_RE = /^([ \t]*(?:\/\*.*)?)@import\s+["']([^"']+(?:\.scss|\.sass)?)["'];?([ \t]*(?:\/[/*].*)?)$/gm;
10
+
11
+ module.exports = async function sassGlobLoader(content) {
12
+ // console.log(`Sass glob loader for ${this.resourcePath}`);
13
+
14
+ const file = this.resourcePath;
15
+ const base = path.dirname(file);
16
+
17
+ const newContent = content.replace(
18
+ IMPORT_RE,
19
+ (importRule, startComment, globPattern, endComment) => {
20
+ if (globby.hasMagic(globPattern)) {
21
+ const files = globby.sync(globPattern, { cwd: base }).sort();
22
+
23
+ const filesString = files.map((f) => `@import '${f}';`).join('\n');
24
+
25
+ // Inlining sources here makes sass build even faster
26
+ // but breaks source maps
27
+ // const filesString = files
28
+ // .map((f) => fs.readFileSync(path.join(base, f), 'utf8'))
29
+ // .join('\n');
30
+
31
+ return startComment + filesString + endComment;
32
+ }
33
+
34
+ return importRule;
35
+ },
36
+ );
37
+
38
+ // console.log(newContent);
39
+
40
+ return newContent;
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chisel-scripts",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0",
4
4
  "description": "TODO",
5
5
  "bin": {
6
6
  "chisel-scripts": "bin/chisel-scripts.js"
@@ -30,13 +30,12 @@
30
30
  "@babel/core": "^7.10.2",
31
31
  "babel-loader": "^8.1.0",
32
32
  "case-sensitive-paths-webpack-plugin": "^2.3.0",
33
- "chisel-shared-utils": "^1.0.0-alpha.0",
33
+ "chisel-shared-utils": "^1.0.0",
34
34
  "cli-highlight": "^2.1.4",
35
35
  "cliui": "^6.0.0",
36
36
  "commander": "^5.1.0",
37
37
  "css-loader": "^3.5.3",
38
38
  "cssnano": "^4.1.10",
39
- "fibers": "^5.0.0",
40
39
  "file-loader": "^6.0.0",
41
40
  "fs-extra": "^9.0.1",
42
41
  "globby": "^11.0.1",
@@ -61,5 +60,8 @@
61
60
  "webpack-merge": "^4.2.2",
62
61
  "webpackbar": "^4.0.0"
63
62
  },
64
- "gitHead": "9038a3ab2803b992c9d6cee939d903617e9b8f0f"
63
+ "optionalDependencies": {
64
+ "fibers": "^5.0.0"
65
+ },
66
+ "gitHead": "a879e91b61e119d27439c9bd9e7298c89776a4fb"
65
67
  }