mirror of
https://github.com/xxxsf/vue3-h5-template.git
synced 2025-04-05 20:35:49 +08:00
Feat 最干净的脚手架
This commit is contained in:
parent
86883b17a0
commit
988be8c875
@ -1,9 +0,0 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
end_of_line = lf
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
.idea/
|
|
@ -1 +0,0 @@
|
|||||||
theme: jekyll-theme-cayman
|
|
@ -1,45 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
/* 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()
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,72 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,60 +0,0 @@
|
|||||||
var path = require('path')
|
|
||||||
var config = require('../config')
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
@ -1,10 +1,3 @@
|
|||||||
/*
|
|
||||||
* @Description:
|
|
||||||
* @Autor: shunfa.xu
|
|
||||||
* @Date: 2020-05-21 15:55:54
|
|
||||||
* @LastEditors: shunfa.xu
|
|
||||||
* @LastEditTime: 2020-05-22 15:07:20
|
|
||||||
*/
|
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const config = require('./webpack.prod.conf');
|
const config = require('./webpack.prod.conf');
|
||||||
|
|
||||||
|
8719
package-lock.json
generated
8719
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
||||||
"start": "node build/dev-server.js",
|
|
||||||
"build": "node build/build.js"
|
"build": "node build/build.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user