From 0dbf6fd18a6103c924d174725333caeb8fe22de3 Mon Sep 17 00:00:00 2001 From: gijsroge Date: Mon, 25 May 2020 20:37:50 +0200 Subject: [PATCH] #172 added support for module bundling using Rollup --- gulpfile.js | 29 +++++- lib/gulp/js.js | 108 ++++++++++---------- package-lock.json | 213 +++++++++++++++++++++++++++++++++++++++ package.json | 7 ++ test/js/.buildozerrc | 14 +++ test/js/dist/js/index.js | 1 + test/js/js/foo.js | 3 + test/js/js/index.js | 2 + 8 files changed, 318 insertions(+), 59 deletions(-) create mode 100644 test/js/.buildozerrc create mode 100644 test/js/dist/js/index.js create mode 100644 test/js/js/foo.js create mode 100644 test/js/js/index.js diff --git a/gulpfile.js b/gulpfile.js index 6395071..8cc6d43 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,8 @@ const gulp = require('gulp'); const configs = require('./lib/gulp/configs.js'); +const {generateBundle} = require('./lib/gulp/js.js'); +const glob = require('util').promisify(require('glob')); // Get all tasks const clean = require('./lib/gulp/clean.js'); @@ -30,15 +32,34 @@ async function watchFiles() { cssCompile({src: item.src, dest: item.dest}); }); - config.js.forEach(j => { + config.js.forEach(async j => { // Watch JS files, we name the function so that Gulp outputs the correct name + const files = await glob(j.src, {absolute: true}); + + let dependencyTree = await Promise.all(files.map(async src => { + const bundle = await generateBundle({src, cwd: j.cwd}); + return bundle.watchFiles; + })); + + dependencyTree = dependencyTree + .flat() + // https://github.com/jlmakes/karma-rollup-preprocessor/issues/30 + .filter(dependency => !dependency.includes('\u0000')); + // eslint-disable-next-line func-names - gulp.watch(j.watch, function js() { - return jsCompile({src: j.src, dest: j.dest, cwd: config.cwd, browserSync}); + gulp.watch(dependencyTree, function js() { + return Promise.all(files.map(async file => { + return jsCompile({ + src: file, + dest: j.dest, + cwd: config.cwd, + browserSync + }); + })); }); // Compile JS once at watch startup - jsCompile({src: j.src, dest: j.dest}); + await Promise.all(files.map(async file => jsCompile({src: file, dest: j.dest, cwd: config.cwd, browserSync}))); }); config['js-concat'].forEach(js => { diff --git a/lib/gulp/js.js b/lib/gulp/js.js index 3d7bca3..983a836 100644 --- a/lib/gulp/js.js +++ b/lib/gulp/js.js @@ -1,12 +1,14 @@ -const babel = require('gulp-babel'); -const terser = require('gulp-terser'); -const presetEnv = require('@babel/preset-env'); const concat = require('gulp-concat'); const gulp = require('gulp'); -const gulpIf = require('gulp-if'); const {cosmiconfigSync} = require('cosmiconfig'); -const eslint = require('gulp-eslint'); const plumber = require('gulp-plumber'); +const {babel} = require('@rollup/plugin-babel'); +const {eslint} = require('rollup-plugin-eslint'); +const {rollup} = require('rollup'); +const resolve = require('@rollup/plugin-node-resolve'); +const commonjs = require('@rollup/plugin-commonjs'); +const glob = require('util').promisify(require('glob')); +const {terser} = require('rollup-plugin-terser'); const configs = require('./configs.js'); async function js() { @@ -15,8 +17,9 @@ async function js() { const configurations = await configs.then(configurations => { configurations.forEach(config => { - jsTasks = jsTasks.concat(config.js.map(js => { - return jsCompile({src: js.src, dest: js.dest, cwd: config.cwd}); + jsTasks = jsTasks.concat(config.js.map(async js => { + const files = await glob(js.src, {absolute: true}); + return Promise.all(files.map(async file => jsCompile({src: file, dest: js.dest, cwd: config.cwd}))); })); }); return configurations; @@ -33,44 +36,51 @@ async function js() { return Promise.all(jsConcatTasks); } -function jsCompile({src, dest, cwd, browserSync = false}) { - return new Promise( - (async resolve => { // eslint-disable-line no-async-promise-executor - let stream = gulp - .src(src); +async function generateBundle({src, cwd}) { + const rollupPlugins = []; - // Prevent errors from aborting task when files are being watched - if (process.argv.includes('watch')) { - stream = stream.pipe(plumber()); - } + // Bundle third party imported modules + rollupPlugins.push(resolve.default()); - // Enable linting if configured - const eslintConfig = cosmiconfigSync('eslint').search(cwd); - if (eslintConfig) { - stream = stream.pipe(eslint({ - fix: process.argv.includes('--fix') - })) - .pipe(gulpIf(file => file.eslint !== null && file.eslint.fixed, gulp.dest(file => file._base))) - .pipe(eslint.format()); - } + // Auto convert CommonJS modules to ES6, so they can be included in a Rollup bundle + rollupPlugins.push(commonjs()); - stream = stream.pipe(babel({ - presets: [presetEnv] - })); + // If user has an eslint configuration, load Eslint. + const hasEslintConfig = Boolean(cosmiconfigSync('eslint').search(cwd)); + if (hasEslintConfig) { + rollupPlugins.push(eslint({fix: process.argv.includes('--fix')})); + } - if (process.env.NODE_ENV === 'production') { - stream = stream.pipe(terser()); - } + // Decide whether to load a default babel preset if there is no babel configuration found + const hasBabelConfig = Boolean(cosmiconfigSync('babel').search(cwd)); + const babelConfig = {babelHelpers: 'bundled'}; + if (!hasBabelConfig) { + babelConfig.presets = ['@babel/preset-env']; + } - stream = stream.pipe(gulp.dest(dest)); + rollupPlugins.push(babel(babelConfig)); - if (browserSync !== false) { - stream.pipe(browserSync.stream({match: '**/*.js'})); - } + // Terser (minify) + rollupPlugins.push(terser()); - stream.on('end', resolve); - }) - ); + return rollup({ + input: src, + plugins: rollupPlugins + }); +} + +async function jsCompile({src, dest, cwd, browserSync = false}) { + const bundle = await generateBundle({src, cwd}); + + if (browserSync) { + browserSync.watch(bundle.watchFiles).on('change', browserSync.reload); + } + + return bundle.write({ + dir: dest, + format: 'cjs', + sourcemap: process.env.NODE_ENV !== 'production' + }); } function jsConcat({src, dest, name, browserSync = false}) { @@ -78,22 +88,10 @@ function jsConcat({src, dest, name, browserSync = false}) { (async resolve => { // eslint-disable-line no-async-promise-executor let stream = gulp.src(src); - // Prevent errors from aborting task when files are being watched - if (process.argv.includes('watch')) { - stream = stream.pipe(plumber()); - } - - stream = stream.pipe(plumber()) - .pipe(babel({ - presets: [presetEnv] - })) - .pipe(concat(name)); - - if (process.env.NODE_ENV === 'production') { - stream = stream.pipe(terser()); - } - - stream = stream.pipe(gulp.dest(dest)); + stream = stream + .pipe(plumber()) + .pipe(concat(name)) + .pipe(gulp.dest(dest)); if (browserSync !== false) { stream.pipe(browserSync.stream({match: '**/*.js'})); @@ -104,4 +102,4 @@ function jsConcat({src, dest, name, browserSync = false}) { ); } -module.exports = {js, jsCompile, jsConcat}; +module.exports = {js, jsCompile, jsConcat, generateBundle}; diff --git a/package-lock.json b/package-lock.json index 948271a..670e793 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1025,6 +1025,73 @@ "fastq": "^1.6.0" } }, + "@rollup/plugin-babel": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.0.2.tgz", + "integrity": "sha512-GiL7jL+FGppzQ1Sn4y2ER4UYXlgXFFEt+sHm4WJEzQwI76Yf9oy2QDqIvcon6xApZWlik3L8fezRGC6Mj2vRXg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.7.4", + "@rollup/pluginutils": "^3.0.8" + } + }, + "@rollup/plugin-commonjs": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-12.0.0.tgz", + "integrity": "sha512-8+mDQt1QUmN+4Y9D3yCG8AJNewuTSLYPJVzKKUZ+lGeQrI+bV12Tc5HCyt2WdlnG6ihIL/DPbKRJlB40DX40mw==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.8", + "commondir": "^1.0.1", + "estree-walker": "^1.0.1", + "glob": "^7.1.2", + "is-reference": "^1.1.2", + "magic-string": "^0.25.2", + "resolve": "^1.11.0" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + } + } + }, + "@rollup/plugin-node-resolve": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.0.0.tgz", + "integrity": "sha512-5poJCChrkVggXXND/sQ7yNqwjUNT4fP31gpRWCnSNnlXuUXTCMHT33xZrTGxgjm5Rl18MHj7iEzlCT8rYWwQSA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.8", + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "deep-freeze": "^0.0.1", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.14.2" + } + }, + "@rollup/pluginutils": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.10.tgz", + "integrity": "sha512-d44M7t+PjmMrASHbhgpSbVgtL6EFyX7J4mYxwQ/c5eoaE6N2VgCgEcWVzNnwycIloti+/MpwFr8qfw+nRw00sw==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + } + } + }, "@sindresorhus/is": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz", @@ -1067,6 +1134,12 @@ "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", "dev": true }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -1118,6 +1191,15 @@ "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.2.tgz", "integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==" }, + "@types/resolve": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", + "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/unist": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz", @@ -2934,6 +3016,12 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, + "builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true + }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -4231,6 +4319,12 @@ "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" }, + "deep-freeze": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deep-freeze/-/deep-freeze-0.0.1.tgz", + "integrity": "sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ=", + "dev": true + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -4245,6 +4339,12 @@ "core-assert": "^0.2.0" } }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "default-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", @@ -5620,6 +5720,12 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" }, + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -9124,6 +9230,12 @@ "js-types": "^1.0.0" } }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, "is-natural-number": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", @@ -9208,6 +9320,15 @@ "proto-props": "^2.0.0" } }, + "is-reference": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.1.4.tgz", + "integrity": "sha512-uJA/CDPO3Tao3GTrxYn6AwkM4nUPJiGGYu5+cB8qbC7WGFlrKZbiRo7SFKxUAEpFUfiHofWCXBUNhvYJMh+6zw==", + "dev": true, + "requires": { + "@types/estree": "0.0.39" + } + }, "is-regex": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", @@ -9341,6 +9462,27 @@ "is-object": "^1.0.1" } }, + "jest-worker": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz", + "integrity": "sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==", + "dev": true, + "requires": { + "merge-stream": "^2.0.0", + "supports-color": "^6.1.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -9996,6 +10138,15 @@ "es5-ext": "~0.10.2" } }, + "magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.4" + } + }, "make-dir": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.2.tgz", @@ -12808,6 +12959,56 @@ "inherits": "^2.0.1" } }, + "rollup": { + "version": "2.10.7", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.10.7.tgz", + "integrity": "sha512-rofUSH2i4GymWhQq6bfRaSiVbz4LEB4h/7+AhuXCaeOSwQqClD0hINjs59j8SyfQwcqe83NcVJAY2kjp0h33bQ==", + "dev": true, + "requires": { + "fsevents": "~2.1.2" + }, + "dependencies": { + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + } + } + }, + "rollup-plugin-eslint": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-eslint/-/rollup-plugin-eslint-7.0.0.tgz", + "integrity": "sha512-u35kXiY11ULeNQGTlRkYx7uGJ/hS/Dx3wj8f9YVC3oMLTGU9fOqQJsAKYtBFZU3gJ8Vt3gu8ppB1vnKl+7gatQ==", + "dev": true, + "requires": { + "eslint": "^6.0.0", + "rollup-pluginutils": "^2.7.1" + } + }, + "rollup-plugin-terser": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.3.0.tgz", + "integrity": "sha512-XGMJihTIO3eIBsVGq7jiNYOdDMb3pVxuzY0uhOE/FM4x/u9nQgr3+McsjzqBn3QfHIpNSZmFnpoKAwHBEcsT7g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "jest-worker": "^24.9.0", + "rollup-pluginutils": "^2.8.2", + "serialize-javascript": "^2.1.2", + "terser": "^4.6.2" + } + }, + "rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "requires": { + "estree-walker": "^0.6.1" + } + }, "run-async": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz", @@ -12928,6 +13129,12 @@ "semver": "^5.3.0" } }, + "serialize-javascript": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", + "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", + "dev": true + }, "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", @@ -13516,6 +13723,12 @@ "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" }, + "sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + }, "sparkles": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.1.tgz", diff --git a/package.json b/package.json index b31acbd..0c32264 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,14 @@ "vinyl-sourcemaps-apply": "^0.2.1" }, "devDependencies": { + "@rollup/plugin-babel": "^5.0.2", + "@rollup/plugin-commonjs": "^12.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", "npm-run-all": "^4.1.5", "rfs": "^9.0.3", + "rollup": "^2.10.7", + "rollup-plugin-eslint": "^7.0.0", + "rollup-plugin-terser": "^5.3.0", "xo": "^0.30.0" }, "scripts": { @@ -60,6 +66,7 @@ "test-config-search": "node bin/buildozer build --cwd=test/config-search", "test-stylelint": "node bin/buildozer build --cwd=test/stylelint", "test-eslint": "node bin/buildozer build --cwd=test/eslint", + "test-js": "node bin/buildozer build --cwd=test/js", "test-fails": "node test/fail-tests.js", "diff-check": "node test/check-diff.js" }, diff --git a/test/js/.buildozerrc b/test/js/.buildozerrc new file mode 100644 index 0000000..24aad7d --- /dev/null +++ b/test/js/.buildozerrc @@ -0,0 +1,14 @@ +src_base_path: ./ +dest_base_path: ./ +img: [] +js: + - src: js/index.js + dest: dist/js +js-concat: [] +svg-sprite: [] +browsersync: + server: null # Static sites + proxy: null # Dynamic sites + reload: null # Glob to watch for reload +config_search: + enabled: false diff --git a/test/js/dist/js/index.js b/test/js/dist/js/index.js new file mode 100644 index 0000000..8e5f8bc --- /dev/null +++ b/test/js/dist/js/index.js @@ -0,0 +1 @@ +"use strict";console.log((function(){console.log("foo")})); diff --git a/test/js/js/foo.js b/test/js/js/foo.js new file mode 100644 index 0000000..c73dbed --- /dev/null +++ b/test/js/js/foo.js @@ -0,0 +1,3 @@ +export default function foo () { + console.log('foo') +} diff --git a/test/js/js/index.js b/test/js/js/index.js new file mode 100644 index 0000000..bb3e900 --- /dev/null +++ b/test/js/js/index.js @@ -0,0 +1,2 @@ +import foo from "./foo"; +console.log(foo);