Skip to content

Commit

Permalink
feat(webpack): including react and vue
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jan 3, 2016
1 parent ba7000e commit 55fb83a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
29 changes: 19 additions & 10 deletions lib/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tooling</title>
</head>
<body>
<div id="app"></div>
<script src="/build/bundle.js"></script>
</body>
</html>
<html{% if(o.htmlWebpackPlugin.files.manifest) { %} manifest="{%= o.htmlWebpackPlugin.files.manifest %}"{% } %}>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<title>{%=o.htmlWebpackPlugin.options.title || 'Webpack App'%}</title>
{% if (o.htmlWebpackPlugin.files.favicon) { %}
<link rel="shortcut icon" href="{%=o.htmlWebpackPlugin.files.favicon%}">
{% } %}
{% for (var css in o.htmlWebpackPlugin.files.css) { %}
<link href="{%=o.htmlWebpackPlugin.files.css[css] %}" rel="stylesheet">
{% } %}
</head>
<body>
<app></app>
{% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %}
<script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry %}"></script>
{% } %}
</body>
</html>
11 changes: 7 additions & 4 deletions lib/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const path = require('path')
const webpack = require('webpack')
const localConfig = require(process.cwd() + '/package.json').tooling || {}
const pathExists = require('path-exists')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
Expand Down Expand Up @@ -64,10 +63,12 @@ module.exports = function (type, options) {
presets: [require('babel-preset-es2015'), require('babel-preset-stage-0'), require('babel-preset-react')],
plugins: [require('babel-plugin-transform-runtime')]
},
plugins: [

]
plugins: []
}
let localConfig = {}
if (pathExists.sync(process.cwd() + '/package.json')) {
localConfig = require(process.cwd() + '/package.json').tooling || {}
}
const index = localConfig.index || {}
if (type === 'build') {
config.output.filename = 'bundle.[chunkhash].js'
Expand All @@ -87,6 +88,7 @@ module.exports = function (type, options) {
}),
new HtmlWebpackPlugin(Object.assign({}, {
title: 'Tooling',
template: __dirname + '/index.html'
}, index)),
new ExtractTextPlugin('styles.[contenthash].css')
]
Expand All @@ -107,6 +109,7 @@ module.exports = function (type, options) {
}),
new HtmlWebpackPlugin(Object.assign({}, {
title: 'Tooling',
template: __dirname + '/index.html'
}, index)),
new ExtractTextPlugin('styles.[contenthash].css')
]
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@
"path-exists": "^2.1.0",
"postcss-loader": "^0.8.0",
"precss": "^1.3.0",
"react": "^0.14.5",
"react-dom": "^0.14.5",
"rucksack-css": "^0.8.5",
"style-loader": "^0.13.0",
"update-notifier": "^0.6.0",
"url-loader": "^0.5.7",
"vue": "^1.0.13",
"vue-hot-reload-api": "^1.2.2",
"vue-html-loader": "^1.0.0",
"vue-loader": "^7.5.0",
Expand Down

0 comments on commit 55fb83a

Please sign in to comment.