@madebyseed/seed-cli-tools 1.5.1 → 1.7.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/.eslintrc CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "env": {
3
- "node": true
3
+ "node": true,
4
+ "es6": true
4
5
  },
5
6
  "parser": "babel-eslint",
6
7
  "extends": "eslint:recommended"
package/lib/config.js CHANGED
@@ -18,7 +18,7 @@ var currentDirectory = __dirname;
18
18
  var themeRoot = (0, _findRoot["default"])(workingDirectory);
19
19
  var defaultGulpPath = (0, _path.join)(themeRoot, (0, _path.normalize)("node_modules/.bin/gulp")); // Legacy path for older versions of Node.
20
20
 
21
- var legacyGulpPath = (0, _path.join)(themeRoot, (0, _path.normalize)("node_modules/seed-cli-tools/node_modules/.bin/gulp"));
21
+ var legacyGulpPath = (0, _path.join)(themeRoot, (0, _path.normalize)("node_modules/@madebyseed/seed-cli-tools/node_modules/.bin/gulp"));
22
22
  var config = {
23
23
  gulpFile: (0, _path.join)(currentDirectory, "gulpfile.js"),
24
24
  gulp: (0, _fs.existsSync)(defaultGulpPath) ? defaultGulpPath : legacyGulpPath,
package/lib/gulpfile.js CHANGED
@@ -1,9 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var gulp = require("gulp"); // imports gulp tasks from the `tasks` directory
3
+ var gulp = require("gulp");
4
+
5
+ var utils = require('./tasks/includes/utilities.js'); // imports gulp tasks from the `tasks` directory
4
6
 
5
7
 
6
8
  require("require-directory")(module, "./tasks");
9
+ /**
10
+ * Handles the error summary at the end if there are errors to output.
11
+ * This task will only be run for the build and zip tasks.
12
+ */
13
+
14
+
15
+ gulp.task('output:errors', function (done) {
16
+ if (utils.hasErrors()) {
17
+ utils.outputErrors();
18
+ } else {
19
+ done();
20
+ }
21
+ });
7
22
  /**
8
23
  * Does a full clean/rebuild of your theme
9
24
  *
@@ -12,7 +27,6 @@ require("require-directory")(module, "./tasks");
12
27
  * @static
13
28
  */
14
29
 
15
-
16
30
  gulp.task("build", gulp.series("clean", gulp.parallel("build:js", "build:vendor-js", "build:css", "build:assets", "build:svg")));
17
31
  /**
18
32
  * Does a full clean/rebuild of your theme and creates a `.zip` compatible with
@@ -25,7 +39,7 @@ gulp.task("build", gulp.series("clean", gulp.parallel("build:js", "build:vendor-
25
39
 
26
40
  gulp.task("zip", gulp.series("build", "shopify:package:dist", "copy:zip"));
27
41
  /**
28
- * Syncronizes the development theme settings with our src folder theme settings
42
+ * Synchronizes the development theme settings with our src folder theme settings
29
43
  *
30
44
  * @function sync-settings
31
45
  * @memberof seed-cli.tasks.deploy
@@ -43,7 +57,7 @@ gulp.task("sync-settings", gulp.series("generate:tmp", "shopify:pull:dev:tmp", "
43
57
  * @static
44
58
  */
45
59
 
46
- gulp.task("watch", gulp.series("build", gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist")));
60
+ gulp.task("watch", gulp.series("build", "output:errors", gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist")));
47
61
  /**
48
62
  *
49
63
  * @summary pulls theme from specified environment theme into src
@@ -10,15 +10,21 @@ var postcss = require("gulp-postcss");
10
10
 
11
11
  var plumber = require("gulp-plumber");
12
12
 
13
+ var gulpif = require("gulp-if");
14
+
13
15
  var chokidar = require("chokidar");
14
16
 
15
17
  var config = require("./includes/config.js");
16
18
 
17
19
  var messages = require("./includes/messages.js");
18
20
 
19
- var tailwindConfig = require(path.join(config.themeRoot, config.tailwindConfig));
21
+ var utils = require("./includes/utilities");
22
+
23
+ var _require = require("./includes/config.js"),
24
+ usesTailwind = _require.usesTailwind;
20
25
 
21
- var assets = tailwindConfig.mode === "jit" ? [config.src.css, config.src.sections, config.src.layout, config.src.snippets, config.src.assets, config.src.js, config.src.icons, config.tailwindConfig] : [config.src.css, config.tailwindConfig];
26
+ var tailwindConfig = config.usesTailwind ? require(path.join(config.themeRoot, config.tailwindConfig)) : {};
27
+ var assets = config.usesTailwind || tailwindConfig.mode === "jit" ? [config.src.css, config.src.sections, config.src.layout, config.src.snippets, config.src.assets, config.src.js, config.src.icons, config.tailwindConfig] : [config.src.css, config.tailwindConfig];
22
28
  /**
23
29
  * Concatenate css via gulp-cssimport and copys to the `/dist` folder
24
30
  *
@@ -28,7 +34,7 @@ var assets = tailwindConfig.mode === "jit" ? [config.src.css, config.src.section
28
34
  */
29
35
 
30
36
  function processCss() {
31
- return gulp.src(config.roots.css).pipe(plumber()).pipe(postcss(config.plugins.postcss)).pipe(sass().on("error", sass.logError)).pipe(gulp.dest(config.dist.assets));
37
+ return gulp.src(config.roots.css).pipe(plumber(utils.errorHandler)).pipe(gulpif(!usesTailwind, sass())).pipe(postcss(config.plugins.postcss)).pipe(gulpif(usesTailwind, sass())).pipe(gulp.dest(config.dist.assets));
32
38
  }
33
39
  /**
34
40
  * Concatenate css via gulp-cssimport
@@ -54,7 +60,7 @@ gulp.task("watch:css", function () {
54
60
  chokidar.watch(assets, {
55
61
  ignoreInitial: true
56
62
  }).on("all", function (event, path) {
57
- var isCssFile = /.\.css$/.test(path); // Don't log event twice
63
+ var isCssFile = /\.s[ac]ss$/i.test(path); // Don't log event twice
58
64
 
59
65
  if (isCssFile) {
60
66
  messages.logFileEvent(event, path);
@@ -4,7 +4,9 @@ var gulp = require('gulp');
4
4
 
5
5
  var gulpif = require('gulp-if');
6
6
 
7
- var uglify = require('gulp-uglify');
7
+ var uglifyjs = require('uglify-js');
8
+
9
+ var composer = require('gulp-uglify/composer');
8
10
 
9
11
  var include = require('gulp-include');
10
12
 
@@ -12,18 +14,30 @@ var plumber = require('gulp-plumber');
12
14
 
13
15
  var chokidar = require('chokidar');
14
16
 
17
+ var minify = composer(uglifyjs, console);
18
+
19
+ var gulpWebpack = require('webpack-stream');
20
+
21
+ var webpack = require('webpack');
22
+
23
+ var utils = require("./includes/utilities");
24
+
15
25
  var config = require('./includes/config.js');
16
26
 
17
27
  var messages = require('./includes/messages.js');
18
28
 
19
29
  function processThemeJs() {
20
30
  messages.logProcessFiles('build:js');
21
- return gulp.src([config.roots.js, "!".concat(config.roots.vendorJs)]).pipe(plumber()).pipe(include()).pipe(gulpif(config.optimize, uglify())).pipe(gulp.dest(config.dist.assets));
31
+ return gulp.src([config.roots.js, "!".concat(config.roots.vendorJs)], {
32
+ allowEmpty: true
33
+ }).pipe(plumber(utils.errorHandler)).pipe(gulpif(config.usesModuleBundler, gulpWebpack(config.plugins.webpack, webpack), include())).pipe(gulpif(config.optimize && !config.usesModuleBundler, minify())).pipe(gulp.dest(config.dist.assets));
22
34
  }
23
35
 
24
36
  function processVendorJs() {
25
37
  messages.logProcessFiles('build:vendor-js');
26
- return gulp.src(config.roots.vendorJs).pipe(plumber()).pipe(include()).pipe(uglify({
38
+ return gulp.src(config.roots.vendorJs, {
39
+ allowEmpty: true
40
+ }).pipe(plumber()).pipe(include()).pipe(minify({
27
41
  mangle: true,
28
42
  compress: true
29
43
  })).pipe(gulp.dest(config.dist.assets));
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var fs = require('fs');
4
+
3
5
  var join = require("path").join;
4
6
 
5
7
  var logger = require("debug")("seed-tools");
@@ -12,8 +14,12 @@ var cssnano = require("cssnano");
12
14
 
13
15
  var pxtorem = require('postcss-pxtorem');
14
16
 
17
+ var reporter = require('postcss-reporter');
18
+
15
19
  var argv = require("minimist")(process.argv.slice(2));
16
20
 
21
+ var webpack = require('webpack');
22
+
17
23
  var themeRoot = findRoot(process.cwd());
18
24
  var tailwindConfig = 'tailwind.config.js';
19
25
  var pkg = {};
@@ -25,16 +31,6 @@ try {
25
31
  }
26
32
  /**
27
33
  * seed-cli configuration object
28
- * ## Markdown stuff
29
- *
30
- * It's a big description written in `markdown`
31
- *
32
- * Example:
33
- *
34
- * ```javascript
35
- * $('something')
36
- * .something(else);
37
- * ```
38
34
  *
39
35
  * @namespace config
40
36
  * @memberof seed-cli
@@ -60,6 +56,8 @@ var config = {
60
56
  themeRoot: themeRoot,
61
57
  packageJson: pkg,
62
58
  tailwindConfig: tailwindConfig,
59
+ usesTailwind: fs.existsSync(join(themeRoot, tailwindConfig)),
60
+ usesModuleBundler: !!pkg['bundle-js'],
63
61
  seedConfig: "seed.config.js",
64
62
  shopifyIgnore: join(themeRoot, '.shopifyignore'),
65
63
  src: {
@@ -114,24 +112,52 @@ var config = {
114
112
  css: "src/styles/*.{css,scss}"
115
113
  },
116
114
  plugins: {
117
- postcss: [require('postcss-import'), tailwindcss({
118
- config: join(themeRoot, tailwindConfig)
119
- }), require('autoprefixer'), pxtorem({
120
- rootValue: 16,
121
- unitPrecision: 5,
122
- propList: ['*'],
123
- selectorBlackList: [],
124
- replace: true,
125
- mediaQuery: true,
126
- exclude: /node_modules/i
127
- })]
115
+ // Added at runtime
116
+ postcss: [],
117
+ webpack: {
118
+ mode: !argv["skip-optimizations"] ? 'production' : 'development',
119
+ output: {
120
+ filename: 'theme.js'
121
+ },
122
+ resolve: {
123
+ alias: {
124
+ vue: 'vue/dist/vue.esm-bundler.js'
125
+ }
126
+ },
127
+ plugins: [new webpack.DefinePlugin({
128
+ __VUE_OPTIONS_API__: true,
129
+ __VUE_PROD_DEVTOOLS__: false
130
+ })],
131
+ stats: 'none'
132
+ }
128
133
  }
129
134
  };
130
135
 
136
+ if (config.usesTailwind) {
137
+ config.plugins.postcss.push(require('postcss-import'));
138
+ config.plugins.postcss.push(tailwindcss({
139
+ config: join(themeRoot, tailwindConfig)
140
+ }));
141
+ }
142
+
143
+ config.plugins.postcss.push(require('autoprefixer'));
144
+
131
145
  if (config.optimize) {
132
146
  config.plugins.postcss.push(cssnano({
133
147
  preset: "default"
134
148
  }));
135
149
  }
136
150
 
151
+ config.plugins.postcss.push(pxtorem({
152
+ rootValue: 16,
153
+ unitPrecision: 5,
154
+ propList: ['*'],
155
+ selectorBlackList: [],
156
+ replace: true,
157
+ mediaQuery: true,
158
+ exclude: /node_modules/i
159
+ }));
160
+ config.plugins.postcss.push(reporter({
161
+ clearReportedMessages: true
162
+ }));
137
163
  module.exports = config;
@@ -22,8 +22,14 @@ function separatePath(path) {
22
22
 
23
23
  var messages = {
24
24
  logFileEvent: function logFileEvent(event, path) {
25
+ var dist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
25
26
  var pathObject = separatePath(path);
26
- log('change in', chalk.magenta(pathObject.dir), chalk.white('-'), chalk.cyan(event), chalk.yellow(pathObject.file));
27
+
28
+ if (dist) {
29
+ log('updated', chalk.green('dist'), chalk.magenta(pathObject.dir), chalk.white('-'), chalk.cyan(event), chalk.yellow(pathObject.file));
30
+ } else {
31
+ log('change in', chalk.magenta(pathObject.dir), chalk.white('-'), chalk.cyan(event), chalk.yellow(pathObject.file));
32
+ }
27
33
  },
28
34
  logTransferDone: function logTransferDone() {
29
35
  log('Transfer Complete:', chalk.green('File changes successfully synced to store'));
@@ -68,7 +74,7 @@ var messages = {
68
74
  log('File missing:', chalk.yellow('`seed.config.js` does not exist. You need to add a config file before you can make changes to your Shopify store.'));
69
75
  },
70
76
  deployTo: function deployTo(environment) {
71
- log('Initiating deploy to', chalk.bold(environment));
77
+ log('Environment:', chalk.bold(environment));
72
78
  },
73
79
  allDeploysComplete: function allDeploysComplete() {
74
80
  log('Multiple environments:', chalk.green('Deploy completed for all environments in series'));
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _this = void 0;
4
-
5
3
  var chalk = require("chalk");
6
4
 
7
5
  var log = require("fancy-log");
@@ -20,6 +18,15 @@ var errors = [];
20
18
  */
21
19
 
22
20
  var utilities = {
21
+ /**
22
+ * Indicates whether there are errors during build/watch
23
+ *
24
+ * @returns {Boolean}
25
+ */
26
+ hasErrors: function hasErrors() {
27
+ return errors.length > 0;
28
+ },
29
+
23
30
  /**
24
31
  * Handles the output for any errors that might have been captured
25
32
  * during the build and zip Gulp tasks.
@@ -48,8 +55,6 @@ var utilities = {
48
55
  errorHandler: function errorHandler(err) {
49
56
  log(chalk.red(err));
50
57
  errors.push(err);
51
-
52
- _this.emit("end");
53
58
  },
54
59
 
55
60
  /**
@@ -106,17 +111,17 @@ var utilities = {
106
111
  * @param {String} path - relative path to file passed via event
107
112
  */
108
113
  addEvent: function addEvent(event, path) {
109
- var _this2 = this;
114
+ var _this = this;
110
115
 
111
116
  _.each(options.changeEvents, function (eventType) {
112
117
  if (event === eventType) {
113
- _this2.change.push(path);
118
+ _this.change.push(path);
114
119
  }
115
120
  });
116
121
 
117
122
  _.each(options.unlinkEvents, function (eventType) {
118
123
  if (event === eventType) {
119
- _this2.unlink.push(path);
124
+ _this.unlink.push(path);
120
125
  }
121
126
  });
122
127
  }
@@ -129,11 +134,6 @@ var utilities = {
129
134
  * Clears the appropriate cache array after a change/delete function has been
130
135
  * called.
131
136
  *
132
- * Example:
133
- * ```javascript
134
- * // TODO:
135
- * ```
136
- *
137
137
  * @memberof seed-cli.utilities
138
138
  * @method
139
139
  * @param {eventCache} cache - a specific cache object for tracking file events
@@ -10,7 +10,6 @@ var utils = require("./includes/utilities");
10
10
 
11
11
  var messages = require("./includes/messages.js");
12
12
 
13
- var environment = config.environment.split(/\s*,\s*|\s+/)[0];
14
13
  var cache = utils.createEventCache();
15
14
  /**
16
15
  * Aggregate task watching for file changes in `src` and
@@ -40,8 +39,9 @@ gulp.task("watch:dist", function () {
40
39
  ignoreInitial: true
41
40
  });
42
41
  watcher.on("all", function (event, path) {
43
- messages.logFileEvent(event, path);
44
- cache.addEvent(event, path);
45
- messages.deployTo(environment);
42
+ if (!utils.hasErrors()) {
43
+ messages.logFileEvent(event, path, true);
44
+ cache.addEvent(event, path);
45
+ }
46
46
  });
47
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madebyseed/seed-cli-tools",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
4
4
  "description": "Seed CLI Tools",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,11 +45,15 @@
45
45
  "postcss": "^8.3.6",
46
46
  "postcss-import": "^14.0.2",
47
47
  "postcss-pxtorem": "^6.0.0",
48
+ "postcss-reporter": "^7.0.5",
48
49
  "require-directory": "^2.1.1",
49
50
  "sass": "^1.36.0",
50
51
  "tailwindcss": "^2.2.7",
52
+ "uglify-js": "^3.15.3",
51
53
  "vinyl-paths": "^3.0.1",
54
+ "webpack": "^5.72.1",
55
+ "webpack-stream": "^7.0.0",
52
56
  "yargs": "^17.0.1"
53
57
  },
54
- "gitHead": "4d7b75ed265d6bf4df7d0a578641239991f24248"
58
+ "gitHead": "974be44fcc8a575715e52c267296bee81b7eb38a"
55
59
  }
package/src/config.js CHANGED
@@ -11,7 +11,7 @@ const defaultGulpPath = join(themeRoot, normalize("node_modules/.bin/gulp"));
11
11
  // Legacy path for older versions of Node.
12
12
  const legacyGulpPath = join(
13
13
  themeRoot,
14
- normalize("node_modules/seed-cli-tools/node_modules/.bin/gulp")
14
+ normalize("node_modules/@madebyseed/seed-cli-tools/node_modules/.bin/gulp")
15
15
  );
16
16
 
17
17
  const config = {
package/src/gulpfile.js CHANGED
@@ -1,8 +1,22 @@
1
1
  const gulp = require("gulp");
2
2
 
3
+ const utils = require('./tasks/includes/utilities.js');
4
+
3
5
  // imports gulp tasks from the `tasks` directory
4
6
  require("require-directory")(module, "./tasks");
5
7
 
8
+ /**
9
+ * Handles the error summary at the end if there are errors to output.
10
+ * This task will only be run for the build and zip tasks.
11
+ */
12
+ gulp.task('output:errors', (done) => {
13
+ if (utils.hasErrors()) {
14
+ utils.outputErrors();
15
+ } else {
16
+ done();
17
+ }
18
+ });
19
+
6
20
  /**
7
21
  * Does a full clean/rebuild of your theme
8
22
  *
@@ -35,7 +49,7 @@ gulp.task(
35
49
  gulp.task("zip", gulp.series("build", "shopify:package:dist", "copy:zip"));
36
50
 
37
51
  /**
38
- * Syncronizes the development theme settings with our src folder theme settings
52
+ * Synchronizes the development theme settings with our src folder theme settings
39
53
  *
40
54
  * @function sync-settings
41
55
  * @memberof seed-cli.tasks.deploy
@@ -59,6 +73,7 @@ gulp.task(
59
73
  "watch",
60
74
  gulp.series(
61
75
  "build",
76
+ "output:errors",
62
77
  gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist")
63
78
  )
64
79
  );
@@ -110,3 +125,5 @@ gulp.task("deploy", gulp.series("sync-settings", "build", "shopify:push:dist"));
110
125
  */
111
126
  gulp.task("deploy:no-sync", gulp.series("build", "shopify:push:dist"));
112
127
 
128
+
129
+
@@ -3,17 +3,21 @@ const gulp = require("gulp");
3
3
  const sass = require("gulp-sass")(require("sass"));
4
4
  const postcss = require("gulp-postcss");
5
5
  const plumber = require("gulp-plumber");
6
+ const gulpif = require("gulp-if");
6
7
  const chokidar = require("chokidar");
7
8
 
8
9
  const config = require("./includes/config.js");
9
10
  const messages = require("./includes/messages.js");
10
- const tailwindConfig = require(path.join(
11
+ const utils = require("./includes/utilities");
12
+ const { usesTailwind } = require("./includes/config.js");
13
+ const tailwindConfig = config.usesTailwind ? require(path.join(
11
14
  config.themeRoot,
12
15
  config.tailwindConfig
13
- ));
16
+ )) : {};
14
17
 
15
- const assets =
16
- tailwindConfig.mode === "jit"
18
+
19
+ const assets =
20
+ config.usesTailwind || tailwindConfig.mode === "jit"
17
21
  ? [
18
22
  config.src.css,
19
23
  config.src.sections,
@@ -34,12 +38,12 @@ const assets =
34
38
  * @private
35
39
  */
36
40
  function processCss() {
37
- return gulp
38
- .src(config.roots.css)
39
- .pipe(plumber())
41
+ return gulp.src(config.roots.css)
42
+ .pipe(plumber(utils.errorHandler))
43
+ .pipe(gulpif(!usesTailwind, sass()))
40
44
  .pipe(postcss(config.plugins.postcss))
41
- .pipe(sass().on("error", sass.logError))
42
- .pipe(gulp.dest(config.dist.assets));
45
+ .pipe(gulpif(usesTailwind, sass()))
46
+ .pipe(gulp.dest(config.dist.assets))
43
47
  }
44
48
 
45
49
  /**
@@ -62,12 +66,13 @@ gulp.task("build:css", () => {
62
66
  */
63
67
  gulp.task("watch:css", () => {
64
68
  chokidar.watch(assets, { ignoreInitial: true }).on("all", (event, path) => {
65
- const isCssFile = /.\.css$/.test(path);
69
+
70
+ const isCssFile = /\.s[ac]ss$/i.test(path);
66
71
  // Don't log event twice
67
72
  if (isCssFile) {
68
73
  messages.logFileEvent(event, path);
69
74
  }
70
75
 
71
- processCss();
76
+ processCss()
72
77
  });
73
78
  });
@@ -1,28 +1,33 @@
1
1
  const gulp = require('gulp');
2
2
  const gulpif = require('gulp-if');
3
- const uglify = require('gulp-uglify');
3
+ const uglifyjs = require('uglify-js');
4
+ const composer = require('gulp-uglify/composer');
4
5
  const include = require('gulp-include');
5
6
  const plumber = require('gulp-plumber');
6
7
  const chokidar = require('chokidar');
8
+ const minify = composer(uglifyjs, console)
9
+ const gulpWebpack = require('webpack-stream');
10
+ const webpack = require('webpack');
7
11
 
12
+ const utils = require("./includes/utilities");
8
13
  const config = require('./includes/config.js');
9
14
  const messages = require('./includes/messages.js');
10
15
 
11
16
  function processThemeJs() {
12
17
  messages.logProcessFiles('build:js');
13
- return gulp.src([config.roots.js, `!${config.roots.vendorJs}`])
14
- .pipe(plumber())
15
- .pipe(include())
16
- .pipe(gulpif(config.optimize, uglify()))
17
- .pipe(gulp.dest(config.dist.assets));
18
+ return gulp.src([config.roots.js, `!${config.roots.vendorJs}`], { allowEmpty: true })
19
+ .pipe(plumber(utils.errorHandler))
20
+ .pipe(gulpif(config.usesModuleBundler, gulpWebpack(config.plugins.webpack, webpack), include()))
21
+ .pipe(gulpif(config.optimize && !config.usesModuleBundler, minify()))
22
+ .pipe(gulp.dest(config.dist.assets))
18
23
  }
19
24
 
20
25
  function processVendorJs() {
21
26
  messages.logProcessFiles('build:vendor-js');
22
- return gulp.src(config.roots.vendorJs)
27
+ return gulp.src(config.roots.vendorJs, { allowEmpty: true })
23
28
  .pipe(plumber())
24
29
  .pipe(include())
25
- .pipe(uglify({
30
+ .pipe(minify({
26
31
  mangle: true,
27
32
  compress: true,
28
33
  }))
@@ -37,7 +42,7 @@ gulp.task('watch:js', () => {
37
42
  chokidar.watch([config.src.js, `!${config.roots.vendorJs}`, `!${config.src.vendorJs}`], {ignoreInitial: true})
38
43
  .on('all', (event, path) => {
39
44
  messages.logFileEvent(event, path);
40
- processThemeJs();
45
+ processThemeJs()
41
46
  });
42
47
  });
43
48
 
@@ -1,10 +1,13 @@
1
+ const fs = require('fs');
1
2
  const join = require("path").join;
2
3
  const logger = require("debug")("seed-tools");
3
4
  const findRoot = require("find-root");
4
5
  const tailwindcss = require("tailwindcss");
5
6
  const cssnano = require("cssnano");
6
7
  const pxtorem = require('postcss-pxtorem');
8
+ const reporter = require('postcss-reporter');
7
9
  const argv = require("minimist")(process.argv.slice(2));
10
+ const webpack = require('webpack');
8
11
  const themeRoot = findRoot(process.cwd());
9
12
  const tailwindConfig = 'tailwind.config.js'
10
13
 
@@ -18,16 +21,6 @@ try {
18
21
 
19
22
  /**
20
23
  * seed-cli configuration object
21
- * ## Markdown stuff
22
- *
23
- * It's a big description written in `markdown`
24
- *
25
- * Example:
26
- *
27
- * ```javascript
28
- * $('something')
29
- * .something(else);
30
- * ```
31
24
  *
32
25
  * @namespace config
33
26
  * @memberof seed-cli
@@ -53,6 +46,10 @@ const config = {
53
46
 
54
47
  tailwindConfig,
55
48
 
49
+ usesTailwind: fs.existsSync(join(themeRoot, tailwindConfig)),
50
+
51
+ usesModuleBundler: !!pkg['bundle-js'],
52
+
56
53
  seedConfig: "seed.config.js",
57
54
 
58
55
  shopifyIgnore: join(themeRoot, '.shopifyignore'),
@@ -113,25 +110,54 @@ const config = {
113
110
  },
114
111
 
115
112
  plugins: {
116
- postcss: [
117
- require('postcss-import'),
118
- tailwindcss({ config: join(themeRoot, tailwindConfig) }),
119
- require('autoprefixer'),
120
- pxtorem({
121
- rootValue: 16,
122
- unitPrecision: 5,
123
- propList: ['*'],
124
- selectorBlackList: [],
125
- replace: true,
126
- mediaQuery: true,
127
- exclude: /node_modules/i
128
- })
129
- ],
113
+ // Added at runtime
114
+ postcss: [],
115
+
116
+ webpack: {
117
+ mode: !argv["skip-optimizations"] ? 'production' : 'development',
118
+ output: {
119
+ filename: 'theme.js'
120
+ },
121
+ resolve: {
122
+ alias: {
123
+ vue: 'vue/dist/vue.esm-bundler.js',
124
+ },
125
+ },
126
+ plugins: [
127
+ new webpack.DefinePlugin({
128
+ __VUE_OPTIONS_API__: true,
129
+ __VUE_PROD_DEVTOOLS__: false,
130
+ })
131
+ ],
132
+ stats: 'none'
133
+ },
130
134
  },
135
+
136
+
131
137
  };
132
138
 
139
+
140
+ if (config.usesTailwind) {
141
+ config.plugins.postcss.push(require('postcss-import'))
142
+ config.plugins.postcss.push(tailwindcss({ config: join(themeRoot, tailwindConfig) }))
143
+ }
144
+
145
+ config.plugins.postcss.push(require('autoprefixer'))
146
+
133
147
  if (config.optimize) {
134
148
  config.plugins.postcss.push((cssnano({ preset: "default" })))
135
149
  }
136
150
 
151
+ config.plugins.postcss.push(pxtorem({
152
+ rootValue: 16,
153
+ unitPrecision: 5,
154
+ propList: ['*'],
155
+ selectorBlackList: [],
156
+ replace: true,
157
+ mediaQuery: true,
158
+ exclude: /node_modules/i
159
+ }))
160
+
161
+ config.plugins.postcss.push(reporter({ clearReportedMessages: true }))
162
+
137
163
  module.exports = config;
@@ -18,15 +18,26 @@ function separatePath(path) {
18
18
  }
19
19
 
20
20
  const messages = {
21
- logFileEvent: (event, path) => {
21
+ logFileEvent: (event, path, dist = false) => {
22
22
  const pathObject = separatePath(path);
23
23
 
24
- log('change in',
25
- chalk.magenta(pathObject.dir),
26
- chalk.white('-'),
27
- chalk.cyan(event),
28
- chalk.yellow(pathObject.file),
29
- );
24
+ if (dist) {
25
+ log('updated',
26
+ chalk.green('dist'),
27
+ chalk.magenta(pathObject.dir),
28
+ chalk.white('-'),
29
+ chalk.cyan(event),
30
+ chalk.yellow(pathObject.file),
31
+ );
32
+ } else {
33
+ log('change in',
34
+ chalk.magenta(pathObject.dir),
35
+ chalk.white('-'),
36
+ chalk.cyan(event),
37
+ chalk.yellow(pathObject.file),
38
+ );
39
+ }
40
+
30
41
  },
31
42
 
32
43
  logTransferDone: () => {
@@ -102,7 +113,7 @@ const messages = {
102
113
  },
103
114
 
104
115
  deployTo: (environment) => {
105
- log('Initiating deploy to', chalk.bold(environment));
116
+ log('Environment:', chalk.bold(environment));
106
117
  },
107
118
 
108
119
  allDeploysComplete: () => {
@@ -13,6 +13,13 @@ let errors = [];
13
13
  * @memberof seed-cli
14
14
  */
15
15
  const utilities = {
16
+ /**
17
+ * Indicates whether there are errors during build/watch
18
+ *
19
+ * @returns {Boolean}
20
+ */
21
+ hasErrors: () => errors.length > 0,
22
+
16
23
  /**
17
24
  * Handles the output for any errors that might have been captured
18
25
  * during the build and zip Gulp tasks.
@@ -25,7 +32,6 @@ const utilities = {
25
32
  }
26
33
 
27
34
  log(chalk.red(`There were errors during the build:\n`));
28
-
29
35
  errors.forEach((err) => {
30
36
  log(chalk.red(err));
31
37
  });
@@ -44,7 +50,6 @@ const utilities = {
44
50
  log(chalk.red(err));
45
51
  errors.push(err);
46
52
 
47
- this.emit("end");
48
53
  },
49
54
 
50
55
  /**
@@ -125,11 +130,6 @@ const utilities = {
125
130
  * Clears the appropriate cache array after a change/delete function has been
126
131
  * called.
127
132
  *
128
- * Example:
129
- * ```javascript
130
- * // TODO:
131
- * ```
132
- *
133
133
  * @memberof seed-cli.utilities
134
134
  * @method
135
135
  * @param {eventCache} cache - a specific cache object for tracking file events
@@ -5,7 +5,6 @@ const utils = require("./includes/utilities");
5
5
 
6
6
  const messages = require("./includes/messages.js");
7
7
 
8
- const environment = config.environment.split(/\s*,\s*|\s+/)[0];
9
8
  const cache = utils.createEventCache();
10
9
 
11
10
  /**
@@ -42,8 +41,9 @@ gulp.task("watch:dist", () => {
42
41
  });
43
42
 
44
43
  watcher.on("all", (event, path) => {
45
- messages.logFileEvent(event, path);
46
- cache.addEvent(event, path);
47
- messages.deployTo(environment);
44
+ if (!utils.hasErrors()) {
45
+ messages.logFileEvent(event, path, true);
46
+ cache.addEvent(event, path);
47
+ }
48
48
  });
49
49
  });