Skip to content

Commit 9d64cbf

Browse files
author
Bulfair, Matt
committed
Bugfix for watching and cleaning _public patterns
updated the readme corrected the way merge was operating
1 parent e0c6ca4 commit 9d64cbf

File tree

6 files changed

+207
-103
lines changed

6 files changed

+207
-103
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "edition-node-webpack",
33
"description": "A pure wrapper around patternlab-node core, the default pattern engine, and supporting frontend assets.",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"dependencies": {
66
"babel-core": "^6.26.0",
77
"babel-loader": "^7.1.2",
@@ -26,7 +26,7 @@
2626
"start": "yarn patternlab:serve",
2727
"webpack:version": "webpack --v",
2828
"patternlab:build": "webpack --env.prod -p",
29-
"patternlab:serve": "webpack-dev-server --env.dev --hot",
29+
"patternlab:serve": "webpack-dev-server --env.dev --hot --progress --colors",
3030
"patternlab:version": "node patternlab.js version",
3131
"patternlab:help": "node patternlab.js help",
3232
"patternlab:patternsonly": "node patternlab.js patternsonly",

patternlab-config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
"url": "http://localhost",
3131
"port": 3000
3232
},
33+
"webpackMerge": {
34+
"entry":"replace"
35+
},
3336
"styleGuideExcludes": [
3437
],
3538
"defaultPattern": "all",
3639
"defaultShowPatternInfo": false,
37-
"cleanPublic" : false,
40+
"cleanPublic" : true,
3841
"patternExtension": "mustache",
3942
"ignored-extensions" : ["scss", "DS_Store", "less"],
4043
"ignored-directories" : ["scss"],

readme.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ There's two options for installing this version:
3838

3939
**Please note:** Pattern Lab Node uses [npm](https://www.npmjs.com/) to manage project dependencies. To upgrade the webpack edition or to install plug-ins you'll need to be familiar with npm.
4040

41-
### Use npm
41+
### Use npm (yarn)
4242

4343
`npm` is a dependency management and package system which can pull in all of the webpack editions's dependencies for you. To accomplish this:
4444

@@ -91,6 +91,29 @@ To install a specific StarterKit from GitHub type:
9191
9292
yarn patternlab:loadstarterkit --kit=[starterkit-name]
9393
94+
### Pattern Lab - Configuration
95+
96+
Unlike the other editions, there were a few options added just for this edition that allow for easier upgrading, and better flexibility.
97+
98+
#### Setting Dev Server Settings
99+
You can set the url and port number in the configuration for
100+
101+
"server": {
102+
"url": "http://localhost",
103+
"port": 3000
104+
},
105+
106+
#### Setting the Webpack Merge Options
107+
In this edition, it's important to make the configuration for webpack something very easy to update, and very easy to modify. The current setting for webpack merge are described [here.](https://github.com/Comcast/patternlab-edition-node-webpack/blob/master/source/_app/readme.md)
108+
109+
You can change how it merges by changing this object in `patternlab-config.json`:
110+
111+
"webpackMerge": {
112+
"entry":"replace"
113+
},
114+
115+
By default merge does a `append` if that option works for you only set which webpack configuration you want to change. The merge setting is: `smartStrategy` which is documented over on this [page.](https://www.npmjs.com/package/webpack-merge#mergesmartstrategy-key-prependappendreplaceconfiguration--configuration)
116+
94117
### Licenses
95118
* [babel-core](https://github.com/babel/babel/blob/master/LICENSE) - MIT
96119
* [babel-loader](https://github.com/babel/babel-loader/blob/master/LICENSE) -MIT,

source/_app/readme.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ Used to store your app specific files.
66

77
**Custom Webpack Configuration**
88

9-
`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.
9+
`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.
10+
11+
### More information
12+
13+
For details into how webpack merge works, and all the options you can do, check out their page:
14+
[Webpack Merge](https://www.npmjs.com/package/webpack-merge#mergesmartstrategy-key-prependappendreplaceconfiguration--configuration)

webpack.config.babel.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@ const customization = require(`${plConfig.paths.source.app}/webpack.app.js`);
1313

1414
module.exports = env => {
1515
const {ifProd, ifDev} = getIfUtils(env);
16-
const config = merge.smart(customization(env), {
16+
17+
const config = merge.smartStrategy(plConfig.webpackMerge)({
1718
devtool: ifDev('source-map'),
1819
context: resolve(__dirname, 'source'),
1920
node: {
2021
fs: "empty"
2122
},
2223
entry: {
23-
/**
24-
* Gathers any Source JS files and creates a bundle
25-
* Note: To change this, please modify _app/webpack.app.js and use the same key.
26-
*/
24+
// Gathers any Source JS files and creates a bundle
25+
//NOTE: This name can be changed, if so, make sure to update _meta/01-foot.mustache
2726
"js/pl-source":
28-
globby.sync([resolve(plConfig.paths.source.js + '**/*.js')]).map(function (filePath) {
27+
globby.sync([resolve(plConfig.paths.source.js + '**/*.js')]).map(function (filePath) {
2928
return filePath;
3029
})
3130
},
@@ -140,7 +139,7 @@ module.exports = env => {
140139
contentBase: resolve(__dirname, 'public'),
141140
port: plConfig.server.port,
142141
open:true,
143-
watchContentBase: true
142+
watchContentBase: false
144143
},
145144
module: {
146145
rules: [
@@ -158,7 +157,7 @@ module.exports = env => {
158157
}
159158
]
160159
}
161-
})
160+
}, customization(env))
162161

163162
return config
164163
}

0 commit comments

Comments
 (0)