Skip to content

Commit 03d4b5e

Browse files
committed
Initial commit of packaging! 🚀
0 parents  commit 03d4b5e

File tree

7 files changed

+296
-0
lines changed

7 files changed

+296
-0
lines changed

.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"sourceMaps": true,
3+
"presets": [
4+
"es2015-minimal",
5+
"stage-0"
6+
],
7+
"plugins": [
8+
["transform-decorators-legacy"],
9+
["transform-react-jsx", { "pragma": "h" }]
10+
]
11+
}

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[{package.json,.*rc,*.yml}]
11+
indent_style = space
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintrc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"parser": "babel-eslint",
3+
"rules": {
4+
"semi": 2,
5+
"camelcase": 0,
6+
"comma-style": 2,
7+
"comma-dangle": [2, "never"],
8+
"indent": [2, "tab", {"SwitchCase": 1}],
9+
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
10+
"no-trailing-spaces": [2, { "skipBlankLines": true }],
11+
"max-nested-callbacks": [2, 3],
12+
"no-eval": 2,
13+
"no-implied-eval": 2,
14+
"no-new-func": 2,
15+
"guard-for-in": 2,
16+
"eqeqeq": 2,
17+
"no-else-return": 2,
18+
"no-redeclare": 2,
19+
"no-dupe-keys": 2,
20+
"radix": 2,
21+
"strict": [2, "never"],
22+
"no-shadow": 0,
23+
"callback-return": [1, ["callback", "cb", "next", "done"]],
24+
"no-delete-var": 2,
25+
"no-undef-init": 2,
26+
"no-shadow-restricted-names": 2,
27+
"handle-callback-err": 0,
28+
"no-lonely-if": 2,
29+
"space-return-throw-case": 2,
30+
"constructor-super": 2,
31+
"no-this-before-super": 2,
32+
"no-dupe-class-members": 2,
33+
"no-const-assign": 2,
34+
"prefer-spread": 2,
35+
"no-useless-concat": 2,
36+
"no-var": 2,
37+
"object-shorthand": 2,
38+
"prefer-arrow-callback": 2
39+
}
40+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules
2+
/npm-debug.log
3+
/build
4+
.DS_Store

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# `preact-boilerplate`
2+
3+
> Ready-to-go [webpack]-powered [Preact] starter project.
4+
5+
6+
## Installation
7+
8+
**1. Clone this repo:**
9+
10+
```sh
11+
git clone [email protected]:developit/preact-boilerplate.git my-app
12+
cd my-app
13+
```
14+
15+
**2. Make it your own:**
16+
17+
```sh
18+
rm -rf .git && git init && npm init
19+
```
20+
21+
**3. Install the dependencies:**
22+
23+
```sh
24+
npm install
25+
```
26+
27+
**4. Start a live-reload development server:**
28+
29+
```sh
30+
PORT=8080 npm run dev
31+
```
32+
33+
**5. Generate a production build in `./build`:**
34+
35+
```sh
36+
npm run build
37+
```
38+
39+
40+
## License
41+
42+
MIT
43+
44+
45+
[Preact]: https://developit.github.io/preact
46+
[webpack]: https://webpack.github.io

package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "preact-boilerplate",
3+
"version": "0.1.0",
4+
"description": "Ready-to-go Preact starter project powered by webpack.",
5+
"scripts": {
6+
"dev": "NODE_ENV=development webpack-dev-server --inline --progress",
7+
"start": "superstatic build -p ${PORT:-8080} --gzip -c '{\"routes\":{\"**\":\"index.html\"},\"cache_control\":{\"**\":86400}}'",
8+
"prestart": "npm run build",
9+
"build": "NODE_ENV=production webpack -p --progress",
10+
"prebuild": "mkdir -p build && ncp src/assets build/assets",
11+
"test": "eslint src tests/**/*.js"
12+
},
13+
"keywords": [
14+
"preact",
15+
"boilerplate",
16+
"webpack"
17+
],
18+
"license": "MIT",
19+
"author": "Jason Miller <[email protected]>",
20+
"devDependencies": {
21+
"autoprefixer": "^6.3.1",
22+
"babel": "^6.3.26",
23+
"babel-core": "^6.4.0",
24+
"babel-eslint": "^5.0.0-beta6",
25+
"babel-loader": "^6.2.1",
26+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
27+
"babel-plugin-transform-react-jsx": "^6.4.0",
28+
"babel-preset-es2015": "^6.3.13",
29+
"babel-preset-es2015-minimal": "^1.0.0",
30+
"babel-preset-stage-0": "^6.3.13",
31+
"babel-register": "^6.4.3",
32+
"babel-runtime": "^6.3.19",
33+
"chai": "^3.4.1",
34+
"core-js": "^2.0.3",
35+
"css-loader": "^0.23.1",
36+
"eslint": "^1.10.3",
37+
"extract-text-webpack-plugin": "^1.0.1",
38+
"file-loader": "^0.8.5",
39+
"html-webpack-plugin": "^1.7.0",
40+
"json-loader": "^0.5.4",
41+
"less": "^2.5.3",
42+
"less-loader": "^2.2.2",
43+
"ncp": "^2.0.0",
44+
"npm-run-all": "^1.5.0",
45+
"postcss-loader": "^0.8.0",
46+
"raw-loader": "^0.5.1",
47+
"source-map-loader": "^0.1.5",
48+
"superstatic": "^4.0.1",
49+
"url-loader": "^0.5.7",
50+
"webpack": "^1.12.11",
51+
"webpack-dev-server": "^1.14.1"
52+
},
53+
"dependencies": {
54+
"decko": "^1.1.3",
55+
"preact": "^2.7.3",
56+
"preact-compat": "^0.4.0",
57+
"preact-router": "^1.1.0",
58+
"proptypes": "^0.14.1"
59+
}
60+
}

webpack.config.babel.js

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import webpack from 'webpack';
2+
import ExtractTextPlugin from 'extract-text-webpack-plugin';
3+
import HtmlWebpackPlugin from 'html-webpack-plugin';
4+
import autoprefixer from 'autoprefixer';
5+
6+
const ENV = process.env.NODE_ENV || 'development';
7+
const MAP = ENV==='production' ? '' : '?sourceMap';
8+
9+
module.exports = {
10+
entry: './src/index.js',
11+
12+
output: {
13+
path: './build',
14+
publicPath: '/',
15+
filename: 'bundle.js'
16+
},
17+
18+
resolve: {
19+
extensions: ['', '.jsx', '.js', '.json', '.less'],
20+
modulesDirectories: [
21+
`${__dirname}/src/lib`,
22+
`${__dirname}/node_modules`,
23+
'node_modules'
24+
],
25+
alias: {
26+
components: `${__dirname}/src/components`, // used for tests
27+
style: `${__dirname}/src/style`,
28+
'react': 'preact-compat',
29+
'react-dom': 'preact-compat'
30+
}
31+
},
32+
33+
module: {
34+
preLoaders: [
35+
{
36+
test: /\.jsx?$/,
37+
exclude: /src\//,
38+
loader: 'source-map'
39+
}
40+
],
41+
loaders: [
42+
{
43+
test: /\.jsx?$/,
44+
exclude: /node_modules/,
45+
loader: 'babel'
46+
},
47+
{
48+
test: /\.(less|css)$/,
49+
include: /src\/components\//,
50+
loader: ExtractTextPlugin.extract([
51+
`css${MAP||'?'}&modules&importLoaders=1&localIdentName=[local]${process.env.CSS_MODULES_IDENT || '_[hash:base64:5]'}`,
52+
'postcss',
53+
`less${MAP}`
54+
].join('!'))
55+
},
56+
{
57+
test: /\.(less|css)$/,
58+
exclude: /src\/components\//,
59+
loader: ExtractTextPlugin.extract(`css${MAP}!postcss!less${MAP}`)
60+
},
61+
{
62+
test: /\.json$/,
63+
loader: 'json'
64+
},
65+
{
66+
test: /\.(xml|html|txt)$/,
67+
loader: 'raw'
68+
},
69+
{
70+
test: /\.(svg|woff|ttf|eot)(\?.*)?$/i,
71+
loader: 'file-loader?name=assets/fonts/[name]_[hash:base64:5].[ext]'
72+
}
73+
]
74+
},
75+
76+
postcss: () => [
77+
autoprefixer({ browsers: 'last 2 versions' })
78+
],
79+
80+
plugins: ([
81+
new webpack.NoErrorsPlugin(),
82+
new ExtractTextPlugin('style.css', { allChunks: true }),
83+
new webpack.optimize.DedupePlugin(),
84+
new webpack.DefinePlugin({
85+
'process.env.NODE_ENV': JSON.stringify(ENV)
86+
}),
87+
new HtmlWebpackPlugin({
88+
template: 'src/index.html',
89+
minify: { collapseWhitespace: true }
90+
})
91+
]).concat(ENV==='production' ? [
92+
new webpack.optimize.OccurenceOrderPlugin(),
93+
new webpack.optimize.UglifyJsPlugin({
94+
mangle: true,
95+
compress: true,
96+
comments: false
97+
})
98+
] : []),
99+
100+
stats: { colors: true },
101+
102+
devtool: ENV==='production' ? 'source-map' : 'inline-source-map',
103+
104+
devServer: {
105+
port: process.env.PORT || 8080,
106+
host: '0.0.0.0',
107+
colors: true,
108+
publicPath: '/',
109+
contentBase: './src',
110+
historyApiFallback: true,
111+
proxy: [
112+
// OPTIONAL: proxy configuration:
113+
// {
114+
// path: '/optional-prefix/**',
115+
// target: 'http://target-host.com',
116+
// rewrite: req => { req.url = req.url.replace(/^\/[^\/]+\//, ''); } // strip first path segment
117+
// }
118+
]
119+
}
120+
};

0 commit comments

Comments
 (0)