diff --git a/package.json b/package.json index 2f229de..c8c9082 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,20 @@ { "name": "edition-node-webpack", "description": "A pure wrapper around patternlab-node core, the default pattern engine, and supporting frontend assets.", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-es2015": "^6.24.1", "copy-webpack-plugin": "^4.0.1", "event-hooks-webpack-plugin": "^1.0.0", - "glob": "^7.1.2", + "globby": "^6.1.0", "patternlab-node": "^2.11.0", "styleguidekit-assets-default": "^3.5.0", "styleguidekit-mustache-default": "^3.0.0", "webpack": "^3.5.6", - "webpack-config-utils": "^2.3.0" + "webpack-config-utils": "^2.3.0", + "webpack-merge": "^4.1.0" }, "repository": "git@github.com:Comcast/patternlab-edition-node-webpack.git", "bugs": "https://github.com/Comcast/patternlab-edition-node-webpack/issues", diff --git a/patternlab-config.json b/patternlab-config.json index 39bab1a..b8a95ff 100644 --- a/patternlab-config.json +++ b/patternlab-config.json @@ -2,6 +2,7 @@ "paths": { "source": { "root": "./source/", + "app": "./source/_app", "patterns": "./source/_patterns/", "data": "./source/_data/", "meta": "./source/_meta/", @@ -66,11 +67,12 @@ "patternExportPatternPartials": [], "patternExportDirectory": "./pattern_exports/", "cacheBust": true, - "starterkitSubDir": "dist", + "starterkitPostInstallClean": false, "outputFileSuffixes": { "rendered": ".rendered", "rawTemplate": "", "markupOnly": ".markup-only" }, - "cleanOutputHtml": true + "cleanOutputHtml": true, + "exportToGraphViz": false } \ No newline at end of file diff --git a/readme.md b/readme.md index 7dda210..f9c85c9 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ The webpack wrapper around [Pattern Lab Node Core](https://github.com/pattern-la ## Installation and Starting 1. `yarn install` or `npm install` -2. `yarn start` +2. `yarn start` or `npm run start` ## Packaged Components @@ -97,10 +97,17 @@ To install a specific StarterKit from GitHub type: * [babel-preset-es2015](https://github.com/babel/babel/blob/master/LICENSE) - MIT * [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/LICENSE) - MIT * [event-hooks-webpack-plugin](https://github.com/cascornelissen/event-hooks-webpack-plugin/blob/master/LICENSE.md) - MIT -* [glob](https://github.com/isaacs/node-glob/blob/master/LICENSE) - ISC +* [globby](https://github.com/sindresorhus/globby/blob/master/license) - MIT * [patternlab-node](https://github.com/pattern-lab/patternlab-node/blob/master/LICENSE) - MIT * [styleguidekit-assets-default](https://github.com/pattern-lab/styleguidekit-assets-default/blob/master/LICENSE) - MIT * [styleguidekit-mustache-default](https://github.com/pattern-lab/styleguidekit-mustache-default/blob/master/LICENSE) - MIT * [webpack](https://github.com/webpack/webpack/blob/master/LICENSE) - MIT * [webpack-config-utils](https://github.com/kentcdodds/webpack-config-utils/blob/master/LICENSE) - MIT * [webpack-dev-server](https://github.com/webpack/webpack-dev-server/blob/master/LICENSE) - MIT +* [webpack-merge](https://github.com/survivejs/webpack-merge/blob/master/LICENSE) - MIT + +### Special Thanks and Contributions + +Contributor | Special Thanks +----------- | -------------- + ![@rgualberto](https://avatars3.githubusercontent.com/u/5126167?v=4&s=75)[@rgualberto](https://github.com/rgualberto) | "A huge thank you to a incredible developer [Rodrigo Gualberto](https://github.com/rgualberto) for all of his hard work, dedication, and support from the start of project." diff --git a/source/_app/.gitkeep b/source/_app/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/source/_app/readme.md b/source/_app/readme.md index e4b9674..fb75c05 100644 --- a/source/_app/readme.md +++ b/source/_app/readme.md @@ -1,3 +1,9 @@ # _app -Used to store your app specific files. \ No newline at end of file +Used to store your app specific files. + +## Includes + +**Custom Webpack Configuration** + +`webpack.app.js` this file is used to place your custom webpack configuration. This will merge or override the values in `webpack.config.babel.js` This will provide a way to change your configuration and still get updates in the future. \ No newline at end of file diff --git a/source/_app/webpack.app.js b/source/_app/webpack.app.js new file mode 100644 index 0000000..aa99e50 --- /dev/null +++ b/source/_app/webpack.app.js @@ -0,0 +1,10 @@ +const {getIfUtils} = require('webpack-config-utils'); + +module.exports = env => { + const {ifProd, ifDev} = getIfUtils(env); + + const app = { + //Custom webpack configuration goes here + } + return app; + } diff --git a/webpack.config.babel.js b/webpack.config.babel.js index 23d6ba4..02cc660 100644 --- a/webpack.config.babel.js +++ b/webpack.config.babel.js @@ -1,28 +1,31 @@ // webpack.config.js const webpack = require('webpack'); const {resolve} = require('path'); -const glob = require('glob'); +const globby = require('globby'); const {getIfUtils, removeEmpty} = require('webpack-config-utils'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const EventHooksPlugin = require('event-hooks-webpack-plugin'); const plConfig = require('./patternlab-config.json'); const patternlab = require('patternlab-node')(plConfig); const patternEngines = require('patternlab-node/core/lib/pattern_engines'); - +const merge = require('webpack-merge'); +const customization = require(`${plConfig.paths.source.app}/webpack.app.js`); module.exports = env => { const {ifProd, ifDev} = getIfUtils(env); - const config = ({ + const config = merge.smart(customization(env), { devtool: ifDev('source-map'), context: resolve(__dirname, 'source'), node: { fs: "empty" }, entry: { - // Gathers any Source JS files and creates a bundle - //NOTE: This name can be changed, if so, make sure to update _meta/01-foot.mustache - "js/pl-source": - glob.sync(resolve(plConfig.paths.source.js + '**/*.js')).map(function (filePath) { + /** + * Gathers any Source JS files and creates a bundle + * Note: To change this, please modify _app/webpack.app.js and use the same key. + */ + "js/pl-source": + globby.sync([resolve(plConfig.paths.source.js + '**/*.js')]).map(function (filePath) { return filePath; }) }, @@ -121,7 +124,7 @@ module.exports = env => { const allWatchFiles = watchFiles.concat(templateFilePaths); allWatchFiles.forEach(function(globPath) { - const patternFiles = glob.sync(globPath).map(function (filePath) { + const patternFiles = globby.sync(globPath).map(function (filePath) { return resolve(filePath); }); diff --git a/yarn.lock b/yarn.lock index b711533..c8d103f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1719,7 +1719,7 @@ glob@^6.0.4: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -3812,6 +3812,12 @@ webpack-dev-server@^2.7.1: webpack-dev-middleware "^1.11.0" yargs "^6.6.0" +webpack-merge@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.0.tgz#6ad72223b3e0b837e531e4597c199f909361511e" + dependencies: + lodash "^4.17.4" + webpack-sources@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf"