Skip to content

Commit d844552

Browse files
committed
Merge branch 'master' of github.com:developit/preact-boilerplate into merge-remote
# Conflicts: # package.json # webpack.config.babel.js
2 parents 18eab0f + a1c199a commit d844552

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

.eslintrc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
{
22
"parser": "babel-eslint",
3+
"extends": "eslint:recommended",
4+
"env": {
5+
"browser": true,
6+
"mocha": true,
7+
"es6": true
8+
},
9+
"parserOptions": {
10+
"ecmaFeatures": {
11+
"modules": true,
12+
"jsx": true
13+
}
14+
},
15+
"globals": {},
316
"rules": {
17+
"no-empty": 0,
18+
"no-console": 0,
19+
"no-unused-vars": [0, { "varsIgnorePattern": "^h$" }],
20+
"no-cond-assign": 1,
421
"semi": 2,
522
"camelcase": 0,
623
"comma-style": 2,
@@ -13,14 +30,13 @@
1330
"no-implied-eval": 2,
1431
"no-new-func": 2,
1532
"guard-for-in": 2,
16-
"eqeqeq": 2,
33+
"eqeqeq": 1,
1734
"no-else-return": 2,
1835
"no-redeclare": 2,
1936
"no-dupe-keys": 2,
2037
"radix": 2,
2138
"strict": [2, "never"],
2239
"no-shadow": 0,
23-
"callback-return": [1, ["callback", "cb", "next", "done"]],
2440
"no-delete-var": 2,
2541
"no-undef-init": 2,
2642
"no-shadow-restricted-names": 2,

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Below is a step-by-step guide that takes you straight from downloading this boil
1616
- [Installation](#installation)
1717
- [Development Workflow](#development-workflow)
1818
- [Structure](#structure)
19+
- [CSS Modules](#css-modules)
1920
- [Handling URLS](#handling-urls)
2021

2122

@@ -24,7 +25,7 @@ Below is a step-by-step guide that takes you straight from downloading this boil
2425
**1. Clone this repo:**
2526

2627
```sh
27-
git clone git@github.com:developit/preact-boilerplate.git my-app
28+
git clone --depth 1 https://github.com/developit/preact-boilerplate.git my-app
2829
cd my-app
2930
```
3031

@@ -91,6 +92,36 @@ class Link extends Component {
9192
```
9293

9394

95+
---
96+
97+
98+
## CSS Modules
99+
100+
This project is set up to support [CSS Modules](https://github.com/css-modules/css-modules). By default, styles in `src/style` are **global** (not using CSS Modules) to make global declarations, imports and helpers easy to declare. Styles in `src/components` are loaded as CSS Modules via [Webpack's css-loader](https://github.com/webpack/css-loader#css-modules). Modular CSS namespaces class names, and when imported into JavaScript returns a mapping of canonical (unmodified) CSS classes to their local (namespaced/suffixed) counterparts.
101+
102+
When imported, this LESS/CSS:
103+
104+
```css
105+
.redText { color:red; }
106+
.blueText { color:blue; }
107+
```
108+
109+
... returns the following map:
110+
111+
```js
112+
import styles from './style.css';
113+
console.log(styles);
114+
// {
115+
// redText: 'redText_local_9gt72',
116+
// blueText: 'blueText_local_9gt72'
117+
// }
118+
```
119+
120+
Note that the suffix for local classNames is generated based on an md5 hash of the file. Changing the file changes the hash.
121+
122+
123+
---
124+
94125

95126
## Handling URLS
96127

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "preact-boilerplate",
3-
"version": "1.0.3",
3+
"version": "3.0.0",
44
"description": "Ready-to-go Preact starter project powered by webpack.",
55
"scripts": {
66
"dev": "NODE_ENV=development webpack-dev-server --inline --hot --progress",
@@ -24,7 +24,7 @@
2424
"babel": "^6.5.2",
2525
"babel-core": "^6.7.2",
2626
"babel-eslint": "^5.0.0",
27-
"babel-loader": "^6.2.1",
27+
"babel-loader": "^6.2.4",
2828
"babel-plugin-transform-decorators-legacy": "^1.3.4",
2929
"babel-plugin-transform-react-jsx": "^6.6.5",
3030
"babel-preset-es2015": "^6.6.0",

webpack.config.babel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin';
33
import HtmlWebpackPlugin from 'html-webpack-plugin';
44
import autoprefixer from 'autoprefixer';
55

6+
/*global process,module,__dirname*/
7+
68
const ENV = process.env.NODE_ENV || 'development';
9+
710
const CSS_MAPS = ENV!=='production';
811

912
module.exports = {
@@ -86,11 +89,11 @@ module.exports = {
8689
new webpack.NoErrorsPlugin(),
8790
new ExtractTextPlugin('style.css', {
8891
allChunks: true,
89-
disabled: ENV!=='production'
92+
disable: ENV!=='production'
9093
}),
9194
new webpack.optimize.DedupePlugin(),
9295
new webpack.DefinePlugin({
93-
'process.env.NODE_ENV': JSON.stringify(ENV)
96+
'process.env': JSON.stringify({ NODE_ENV: ENV })
9497
}),
9598
new HtmlWebpackPlugin({
9699
template: 'src/index.html',

0 commit comments

Comments
 (0)