Permalink
Browse files

copy and simplify webpack template

  • Loading branch information...
scriptPilot committed Jan 15, 2017
1 parent c5d06d6 commit 8d8d8e7d86d8fc3fb9bc62a6377b5613202f8fbb
Showing with 26,366 additions and 393 deletions.
  1. +5 −0 .babelrc
  2. +0 −5 .eslintrc.json
  3. +1 −1 .gitignore
  4. 0 LICENCE → LICENSE
  5. +0 −92 README.md.old
  6. +30 −0 build/build.js
  7. +45 −0 build/check-versions.js
  8. +9 −0 build/dev-client.js
  9. +72 −0 build/dev-server.js
  10. +61 −0 build/utils.js
  11. +77 −0 build/webpack.base.conf.js
  12. +34 −0 build/webpack.dev.conf.js
  13. +98 −0 build/webpack.prod.conf.js
  14. +6 −0 config/dev.env.js
  15. +32 −0 config/index.js
  16. +3 −0 config/prod.env.js
  17. 0 {hello-world-app → hello-world-app.old}/app.vue
  18. BIN {hello-world-app → hello-world-app.old}/images/favicon.png
  19. BIN {hello-world-app → hello-world-app.old}/images/flag_de.png
  20. BIN {hello-world-app → hello-world-app.old}/images/flag_en.png
  21. BIN {hello-world-app → hello-world-app.old}/images/theme_ios.png
  22. BIN {hello-world-app → hello-world-app.old}/images/theme_material.png
  23. 0 {hello-world-app → hello-world-app.old}/package.json
  24. 0 {hello-world-app → hello-world-app.old}/pages/home.vue
  25. 0 {hello-world-app → hello-world-app.old}/pages/keepState.vue
  26. 0 {hello-world-app → hello-world-app.old}/pages/minimum.vue
  27. 0 {hello-world-app → hello-world-app.old}/pages/routerTest.vue
  28. 0 {hello-world-app → hello-world-app.old}/pages/withComponents.vue
  29. 0 {hello-world-app → hello-world-app.old}/pages/withoutComponents.vue
  30. 0 index.ejs → index.ejs.old
  31. +15 −0 index.html
  32. 0 {libs → libs.old}/material-icons.css
  33. BIN {libs → libs.old}/material-icons.woff2
  34. BIN {libs → libs.old}/standard-js-sticker-small.png
  35. BIN {libs → libs.old}/standard-js-sticker.png
  36. 0 main.css → main.css.old
  37. +30 −250 main.js
  38. +265 −0 main.js.old
  39. +65 −45 package.json
  40. +51 −0 package.json.old
  41. 0 postinstall.js → postinstall.js.old
  42. +157 −0 src/app.vue
  43. +15 −0 src/pages/about.vue
  44. +31 −0 src/pages/dynamic-route.vue
  45. +132 −0 src/pages/form.vue
  46. +14 −0 src/routes.js
  47. 0 static/.gitkeep
  48. 0 webpack.config.js → webpack.config.js.old
  49. 0 {www → www.old}/.htaccess
  50. +25,095 −0 www.old/build-0.13.0/bundle_dbd64bf0a3c77f397f8b.js
  51. +1 −0 www.old/build-0.13.0/bundle_dbd64bf0a3c77f397f8b.js.map
  52. BIN www.old/build-0.13.0/fonts/Framework7Icons-Regular_1c580a5ddfc3981de69b029b57e1cb8d.woff
  53. BIN www.old/build-0.13.0/fonts/Framework7Icons-Regular_43e6fd7e428b130538053dee7f589ca1.eot
  54. BIN www.old/build-0.13.0/fonts/Framework7Icons-Regular_d9d0fbf7891a152177f204e4a13fda0f.woff2
  55. BIN www.old/build-0.13.0/fonts/Framework7Icons-Regular_f5d76ecc52b90eaeb24bb4566c83ca20.ttf
  56. BIN www.old/build-0.13.0/fonts/material-icons_6fa175ccc464fc232a79826ec5029b5a.woff2
  57. +1 −0 www.old/build-0.13.0/images/Framework7Icons-Regular_46661d6d65debc63884004fed6e37e5c.svg
  58. BIN www.old/build-0.13.0/images/flag_de_69735e17d9742c1be5320e543d080ec0.png
  59. BIN www.old/build-0.13.0/images/flag_en_500a28551b0d2c639c8955861183adf4.png
  60. BIN www.old/build-0.13.0/images/i-f7-ios_959afa9cd537fcddf572ee0c81e23db7.png
  61. BIN www.old/build-0.13.0/images/i-f7-material_9b6b53b75800441feedbbe246366a4b6.png
  62. BIN www.old/build-0.13.0/images/theme_ios_2a65b000cba5bdcc75a2f6609d7df818.png
  63. BIN www.old/build-0.13.0/images/theme_material_8798545563ec6f5879f65ba1b340ea10.png
  64. +1 −0 www.old/build-0.13.0/index.html
  65. +20 −0 www.old/build-0.13.0/manifest.appcache
View
@@ -0,0 +1,5 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"comments": false
}
View

This file was deleted.

Oops, something went wrong.
View
@@ -1,4 +1,4 @@
build-*/
www/build-*
node_modules/
npm-debug.log
*.temp
View
File renamed without changes.
View

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,30 @@
// https://github.com/shelljs/shelljs
require('./check-versions')()
require('shelljs/global')
env.NODE_ENV = 'production'
var path = require('path')
var config = require('../config')
var ora = require('ora')
var webpack = require('webpack')
var webpackConfig = require('./webpack.prod.conf')
var spinner = ora('building for production...')
spinner.start()
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
rm('-rf', assetsPath)
mkdir('-p', assetsPath)
cp('-R', 'static/*', assetsPath)
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n')
})
View
@@ -0,0 +1,45 @@
var semver = require('semver')
var chalk = require('chalk')
var packageConfig = require('../package.json')
var exec = function (cmd) {
return require('child_process')
.execSync(cmd).toString().trim()
}
var versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
},
{
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
}
]
module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
View
@@ -0,0 +1,9 @@
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})
View
@@ -0,0 +1,72 @@
require('./check-versions')()
var config = require('../config')
if (!process.env.NODE_ENV) process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var opn = require('opn')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = require('./webpack.dev.conf')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
var app = express()
var compiler = webpack(webpackConfig)
var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
chunks: false
}
})
var hotMiddleware = require('webpack-hot-middleware')(compiler)
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(context, options))
})
// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(devMiddleware)
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
module.exports = app.listen(port, function (err) {
if (err) {
console.log(err)
return
}
var uri = 'http://localhost:' + port
console.log('Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (process.env.NODE_ENV !== 'testing') {
opn(uri)
}
})
View
@@ -0,0 +1,61 @@
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
exports.assetsPath = function (_path) {
var assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
// generate loader string to be used with extract text plugin
function generateLoaders (loaders) {
var sourceLoader = loaders.map(function (loader) {
var extraParamChar
if (/\?/.test(loader)) {
loader = loader.replace(/\?/, '-loader?')
extraParamChar = '&'
} else {
loader = loader + '-loader'
extraParamChar = '?'
}
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
}).join('!')
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
} else {
return ['vue-style-loader', sourceLoader].join('!')
}
}
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
return {
css: generateLoaders(['css']),
postcss: generateLoaders(['css']),
less: generateLoaders(['css', 'less']),
sass: generateLoaders(['css', 'sass?indentedSyntax']),
scss: generateLoaders(['css', 'sass']),
stylus: generateLoaders(['css', 'stylus']),
styl: generateLoaders(['css', 'stylus'])
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
loader: loader
})
}
return output
}
Oops, something went wrong.

0 comments on commit 8d8d8e7

Please sign in to comment.