diff --git a/.babelrc b/.babelrc index aafe54c99401b4d3122c15531ef59f9c2c4aba0a..3a280ba34b3db923e95e8317b2ee192e012b444b 100644 --- a/.babelrc +++ b/.babelrc @@ -1,13 +1,12 @@ { "presets": [ - ["es2015", { "modules": false }], + ["env", { + "modules": false, + "targets": { + "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] + } + }], "stage-2" ], - "plugins": ["transform-runtime"], - "comments": false, - "env": { - "test": { - "plugins": [ "istanbul" ] - } - } + "plugins": ["transform-vue-jsx", "transform-runtime"] } diff --git a/.postcssrc.js b/.postcssrc.js new file mode 100644 index 0000000000000000000000000000000000000000..249472dab11892e4c3ea004d501700abbcd25229 --- /dev/null +++ b/.postcssrc.js @@ -0,0 +1,9 @@ +// https://github.com/michael-ciniawsky/postcss-load-config + +module.exports = { + "plugins": { + // to edit target browsers: use "browserslist" field in package.json + "postcss-import": {}, + "autoprefixer": {} + } +} diff --git a/build/build.js b/build/build.js index 7e29b911dfb87e3db8426ff38ab119c5e4644e44..8f2ad8ad496a6a0cfba4ea7f90a7b8a3f1f30d6c 100644 --- a/build/build.js +++ b/build/build.js @@ -1,40 +1,41 @@ -// https://github.com/shelljs/shelljs +'use strict' require('./check-versions')() process.env.NODE_ENV = 'production' -var ora = require('ora') -var path = require('path') -var chalk = require('chalk') -var shell = require('shelljs') -var webpack = require('webpack') -var config = require('../config') -var webpackConfig = require('./webpack.prod.conf') +const ora = require('ora') +const rm = require('rimraf') +const path = require('path') +const chalk = require('chalk') +const webpack = require('webpack') +const config = require('../config') +const webpackConfig = require('./webpack.prod.conf') -var spinner = ora('building for production...') +const spinner = ora('building for production...') spinner.start() -var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) -shell.rm('-rf', assetsPath) -shell.mkdir('-p', assetsPath) -shell.config.silent = true -shell.cp('-R', 'static/*', assetsPath) -shell.config.silent = false - -webpack(webpackConfig, function (err, stats) { - spinner.stop() +rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { if (err) throw err - process.stdout.write(stats.toString({ - colors: true, - modules: false, - children: false, - chunks: false, - chunkModules: false - }) + '\n\n') + webpack(webpackConfig, (err, stats) => { + spinner.stop() + if (err) throw err + process.stdout.write(stats.toString({ + colors: true, + modules: false, + children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. + chunks: false, + chunkModules: false + }) + '\n\n') + + if (stats.hasErrors()) { + console.log(chalk.red(' Build failed with errors.\n')) + process.exit(1) + } - console.log(chalk.cyan(' Build complete.\n')) - console.log(chalk.yellow( - ' Tip: built files are meant to be served over an HTTP server.\n' + - ' Opening index.html over file:// won\'t work.\n' - )) + console.log(chalk.cyan(' Build complete.\n')) + console.log(chalk.yellow( + ' Tip: built files are meant to be served over an HTTP server.\n' + + ' Opening index.html over file:// won\'t work.\n' + )) + }) }) diff --git a/build/check-versions.js b/build/check-versions.js index 6548ba18e1a8215936314b104d03f9f34ba4580b..3ef972a08dd51db2cf6c1b5d7f145a5149463e12 100644 --- a/build/check-versions.js +++ b/build/check-versions.js @@ -1,28 +1,35 @@ -var chalk = require('chalk') -var semver = require('semver') -var packageConfig = require('../package.json') +'use strict' +const chalk = require('chalk') +const semver = require('semver') +const packageConfig = require('../package.json') +const shell = require('shelljs') function exec (cmd) { return require('child_process').execSync(cmd).toString().trim() } -var versionRequirements = [ +const versionRequirements = [ { name: 'node', currentVersion: semver.clean(process.version), versionRequirement: packageConfig.engines.node - }, - { + } +] + +if (shell.which('npm')) { + versionRequirements.push({ 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] + const warnings = [] + + for (let i = 0; i < versionRequirements.length; i++) { + const mod = versionRequirements[i] + if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { warnings.push(mod.name + ': ' + chalk.red(mod.currentVersion) + ' should be ' + @@ -35,10 +42,12 @@ module.exports = function () { 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] + + for (let i = 0; i < warnings.length; i++) { + const warning = warnings[i] console.log(' ' + warning) } + console.log() process.exit(1) } diff --git a/build/dev-client.js b/build/dev-client.js deleted file mode 100644 index 18aa1e21952b9468dd5a7e603eb9966d037d2f1a..0000000000000000000000000000000000000000 --- a/build/dev-client.js +++ /dev/null @@ -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() - } -}) diff --git a/build/dev-server.js b/build/dev-server.js deleted file mode 100644 index cc96300bd6f5c5bf4fe05f9954a2f10d262ed3c5..0000000000000000000000000000000000000000 --- a/build/dev-server.js +++ /dev/null @@ -1,81 +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 opn = require('opn') -var path = require('path') -var express = require('express') -var webpack = require('webpack') -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 -// automatically open browser, if not set will be false -var autoOpenBrowser = !!config.dev.autoOpenBrowser -// 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, - quiet: true -}) - -var hotMiddleware = require('webpack-hot-middleware')(compiler, { - log: () => {} -}) -// 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(options.filter || 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')) - -var uri = 'http://localhost:' + port - -devMiddleware.waitUntilValid(function () { - console.log('> Listening at ' + uri + '\n') -}) - -module.exports = app.listen(port, function (err) { - if (err) { - console.log(err) - return - } - - // when env is testing, don't need open it - if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { - opn(uri) - } -}) diff --git a/build/logo.png b/build/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f3d2503fc2a44b5053b0837ebea6e87a2d339a43 Binary files /dev/null and b/build/logo.png differ diff --git a/build/utils.js b/build/utils.js index 7dc098c8dfbc410c8b6af5c85c89032432835469..e534fb0fd6284c53c3ec997bda2822300edd08a3 100644 --- a/build/utils.js +++ b/build/utils.js @@ -1,64 +1,101 @@ -var path = require('path') -var config = require('../config') -var ExtractTextPlugin = require('extract-text-webpack-plugin') +'use strict' +const path = require('path') +const config = require('../config') +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const packageConfig = require('../package.json') exports.assetsPath = function (_path) { - var assetsSubDirectory = process.env.NODE_ENV === 'production' + const assetsSubDirectory = process.env.NODE_ENV === 'production' ? config.build.assetsSubDirectory : config.dev.assetsSubDirectory + return path.posix.join(assetsSubDirectory, _path) } exports.cssLoaders = function (options) { options = options || {} + + const cssLoader = { + loader: 'css-loader', + options: { + sourceMap: options.sourceMap + } + } + + const postcssLoader = { + loader: 'postcss-loader', + options: { + sourceMap: options.sourceMap + } + } + // 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('!') + function generateLoaders (loader, loaderOptions) { + const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] + + if (loader) { + loaders.push({ + loader: loader + '-loader', + options: Object.assign({}, loaderOptions, { + sourceMap: options.sourceMap + }) + }) + } // Extract CSS when that option is specified // (which is the case during production build) if (options.extract) { return ExtractTextPlugin.extract({ - use: sourceLoader, + use: loaders, fallback: 'vue-style-loader' }) } else { - return ['vue-style-loader', sourceLoader].join('!') + return ['vue-style-loader'].concat(loaders) } } - // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html + // https://vue-loader.vuejs.org/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']) + css: generateLoaders(), + postcss: generateLoaders(), + less: generateLoaders('less'), + sass: generateLoaders('sass', { indentedSyntax: true }), + scss: generateLoaders('sass'), + stylus: generateLoaders('stylus'), + styl: generateLoaders('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] + const output = [] + const loaders = exports.cssLoaders(options) + + for (const extension in loaders) { + const loader = loaders[extension] output.push({ test: new RegExp('\\.' + extension + '$'), - loader: loader + use: loader }) } + return output } + +exports.createNotifierCallback = () => { + const notifier = require('node-notifier') + + return (severity, errors) => { + if (severity !== 'error') return + + const error = errors[0] + const filename = error.file && error.file.split('!').pop() + + notifier.notify({ + title: packageConfig.name, + message: severity + ': ' + error.name, + subtitle: filename || '', + icon: path.join(__dirname, 'logo.png') + }) + } +} diff --git a/build/vendor-manifest.json b/build/vendor-manifest.json deleted file mode 100644 index bec02c8929ba2c39c4b275b24e1c82266bca6a38..0000000000000000000000000000000000000000 --- a/build/vendor-manifest.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"vendor_library","content":{"./node_modules/core-js/modules/_export.js":{"id":0,"meta":{}},"./node_modules/core-js/modules/_an-object.js":{"id":1,"meta":{}},"./node_modules/core-js/modules/_global.js":{"id":2,"meta":{}},"./node_modules/core-js/modules/_fails.js":{"id":3,"meta":{}},"./node_modules/core-js/modules/_is-object.js":{"id":4,"meta":{}},"./node_modules/core-js/modules/_wks.js":{"id":5,"meta":{}},"./node_modules/core-js/modules/_descriptors.js":{"id":6,"meta":{}},"./node_modules/core-js/modules/_object-dp.js":{"id":7,"meta":{}},"./node_modules/core-js/modules/_to-length.js":{"id":8,"meta":{}},"./node_modules/core-js/modules/_to-object.js":{"id":9,"meta":{}},"./node_modules/core-js/modules/_has.js":{"id":10,"meta":{}},"./node_modules/core-js/modules/_a-function.js":{"id":11,"meta":{}},"./node_modules/core-js/modules/_hide.js":{"id":12,"meta":{}},"./node_modules/core-js/modules/_redefine.js":{"id":13,"meta":{}},"./node_modules/core-js/modules/_string-html.js":{"id":14,"meta":{}},"./node_modules/core-js/modules/_to-iobject.js":{"id":15,"meta":{}},"./node_modules/axios/lib/utils.js":{"id":16,"meta":{}},"./node_modules/core-js/modules/_object-gopd.js":{"id":17,"meta":{}},"./node_modules/core-js/modules/_object-gpo.js":{"id":18,"meta":{}},"./node_modules/core-js/modules/_cof.js":{"id":19,"meta":{}},"./node_modules/core-js/modules/_defined.js":{"id":20,"meta":{}},"./node_modules/core-js/modules/_strict-method.js":{"id":21,"meta":{}},"./node_modules/core-js/modules/_array-methods.js":{"id":22,"meta":{}},"./node_modules/core-js/modules/_object-sap.js":{"id":23,"meta":{}},"./node_modules/core-js/modules/_to-primitive.js":{"id":24,"meta":{}},"./node_modules/core-js/modules/_core.js":{"id":25,"meta":{}},"./node_modules/core-js/modules/_ctx.js":{"id":26,"meta":{}},"./node_modules/core-js/modules/_metadata.js":{"id":27,"meta":{}},"./node_modules/core-js/modules/_typed-array.js":{"id":28,"meta":{}},"./node_modules/core-js/modules/_meta.js":{"id":29,"meta":{}},"./node_modules/core-js/modules/_property-desc.js":{"id":30,"meta":{}},"./node_modules/core-js/modules/_to-integer.js":{"id":31,"meta":{}},"./node_modules/core-js/modules/_an-instance.js":{"id":32,"meta":{}},"./node_modules/core-js/modules/_library.js":{"id":33,"meta":{}},"./node_modules/core-js/modules/_object-create.js":{"id":34,"meta":{}},"./node_modules/core-js/modules/_object-gopn.js":{"id":35,"meta":{}},"./node_modules/core-js/modules/_object-keys.js":{"id":36,"meta":{}},"./node_modules/core-js/modules/_redefine-all.js":{"id":37,"meta":{}},"./node_modules/core-js/modules/_set-species.js":{"id":38,"meta":{}},"./node_modules/core-js/modules/_to-index.js":{"id":39,"meta":{}},"./node_modules/core-js/modules/_uid.js":{"id":40,"meta":{}},"./node_modules/core-js/modules/_add-to-unscopables.js":{"id":41,"meta":{}},"./node_modules/core-js/modules/_for-of.js":{"id":42,"meta":{}},"./node_modules/core-js/modules/_iterators.js":{"id":43,"meta":{}},"./node_modules/core-js/modules/_set-to-string-tag.js":{"id":44,"meta":{}},"./node_modules/core-js/modules/_string-trim.js":{"id":45,"meta":{}},"./node_modules/core-js/modules/_classof.js":{"id":46,"meta":{}},"./node_modules/core-js/modules/_iobject.js":{"id":47,"meta":{}},"./node_modules/core-js/modules/_object-pie.js":{"id":48,"meta":{}},"./node_modules/core-js/modules/_array-includes.js":{"id":49,"meta":{}},"./node_modules/core-js/modules/_collection.js":{"id":50,"meta":{}},"./node_modules/core-js/modules/_fix-re-wks.js":{"id":51,"meta":{}},"./node_modules/core-js/modules/_flags.js":{"id":52,"meta":{}},"./node_modules/core-js/modules/_invoke.js":{"id":53,"meta":{}},"./node_modules/core-js/modules/_is-regexp.js":{"id":54,"meta":{}},"./node_modules/core-js/modules/_iter-detect.js":{"id":55,"meta":{}},"./node_modules/core-js/modules/_object-forced-pam.js":{"id":56,"meta":{}},"./node_modules/core-js/modules/_object-gops.js":{"id":57,"meta":{}},"./node_modules/core-js/modules/_shared.js":{"id":58,"meta":{}},"./node_modules/core-js/modules/_typed.js":{"id":59,"meta":{}},"./node_modules/axios/lib/defaults.js":{"id":60,"meta":{}},"./node_modules/core-js/modules/_array-fill.js":{"id":61,"meta":{}},"./node_modules/core-js/modules/_create-property.js":{"id":62,"meta":{}},"./node_modules/core-js/modules/_dom-create.js":{"id":63,"meta":{}},"./node_modules/core-js/modules/_enum-bug-keys.js":{"id":64,"meta":{}},"./node_modules/core-js/modules/_fails-is-regexp.js":{"id":65,"meta":{}},"./node_modules/core-js/modules/_html.js":{"id":66,"meta":{}},"./node_modules/core-js/modules/_inherit-if-required.js":{"id":67,"meta":{}},"./node_modules/core-js/modules/_is-array-iter.js":{"id":68,"meta":{}},"./node_modules/core-js/modules/_is-array.js":{"id":69,"meta":{}},"./node_modules/core-js/modules/_iter-create.js":{"id":70,"meta":{}},"./node_modules/core-js/modules/_iter-define.js":{"id":71,"meta":{}},"./node_modules/core-js/modules/_math-expm1.js":{"id":72,"meta":{}},"./node_modules/core-js/modules/_math-sign.js":{"id":73,"meta":{}},"./node_modules/core-js/modules/_microtask.js":{"id":74,"meta":{}},"./node_modules/core-js/modules/_set-proto.js":{"id":75,"meta":{}},"./node_modules/core-js/modules/_shared-key.js":{"id":76,"meta":{}},"./node_modules/core-js/modules/_species-constructor.js":{"id":77,"meta":{}},"./node_modules/core-js/modules/_string-at.js":{"id":78,"meta":{}},"./node_modules/core-js/modules/_string-context.js":{"id":79,"meta":{}},"./node_modules/core-js/modules/_string-repeat.js":{"id":80,"meta":{}},"./node_modules/core-js/modules/_string-ws.js":{"id":81,"meta":{}},"./node_modules/core-js/modules/_task.js":{"id":82,"meta":{}},"./node_modules/core-js/modules/_typed-buffer.js":{"id":83,"meta":{}},"./node_modules/core-js/modules/_wks-define.js":{"id":84,"meta":{}},"./node_modules/core-js/modules/core.get-iterator-method.js":{"id":85,"meta":{}},"./node_modules/core-js/modules/es6.array.iterator.js":{"id":86,"meta":{}},"./node_modules/webpack/buildin/global.js":{"id":87,"meta":{}},"./node_modules/axios/lib/adapters/xhr.js":{"id":88,"meta":{}},"./node_modules/axios/lib/cancel/Cancel.js":{"id":89,"meta":{}},"./node_modules/axios/lib/cancel/isCancel.js":{"id":90,"meta":{}},"./node_modules/axios/lib/core/createError.js":{"id":91,"meta":{}},"./node_modules/axios/lib/helpers/bind.js":{"id":92,"meta":{}},"./node_modules/core-js/modules/_a-number-value.js":{"id":93,"meta":{}},"./node_modules/core-js/modules/_array-copy-within.js":{"id":94,"meta":{}},"./node_modules/core-js/modules/_array-from-iterable.js":{"id":95,"meta":{}},"./node_modules/core-js/modules/_array-reduce.js":{"id":96,"meta":{}},"./node_modules/core-js/modules/_bind.js":{"id":97,"meta":{}},"./node_modules/core-js/modules/_collection-strong.js":{"id":98,"meta":{}},"./node_modules/core-js/modules/_collection-to-json.js":{"id":99,"meta":{}},"./node_modules/core-js/modules/_collection-weak.js":{"id":100,"meta":{}},"./node_modules/core-js/modules/_ie8-dom-define.js":{"id":101,"meta":{}},"./node_modules/core-js/modules/_is-integer.js":{"id":102,"meta":{}},"./node_modules/core-js/modules/_iter-call.js":{"id":103,"meta":{}},"./node_modules/core-js/modules/_iter-step.js":{"id":104,"meta":{}},"./node_modules/core-js/modules/_math-log1p.js":{"id":105,"meta":{}},"./node_modules/core-js/modules/_object-assign.js":{"id":106,"meta":{}},"./node_modules/core-js/modules/_object-dps.js":{"id":107,"meta":{}},"./node_modules/core-js/modules/_object-gopn-ext.js":{"id":108,"meta":{}},"./node_modules/core-js/modules/_object-keys-internal.js":{"id":109,"meta":{}},"./node_modules/core-js/modules/_object-to-array.js":{"id":110,"meta":{}},"./node_modules/core-js/modules/_own-keys.js":{"id":111,"meta":{}},"./node_modules/core-js/modules/_parse-float.js":{"id":112,"meta":{}},"./node_modules/core-js/modules/_parse-int.js":{"id":113,"meta":{}},"./node_modules/core-js/modules/_same-value.js":{"id":114,"meta":{}},"./node_modules/core-js/modules/_string-pad.js":{"id":115,"meta":{}},"./node_modules/core-js/modules/_wks-ext.js":{"id":116,"meta":{}},"./node_modules/core-js/modules/es6.map.js":{"id":117,"meta":{}},"./node_modules/core-js/modules/es6.regexp.flags.js":{"id":118,"meta":{}},"./node_modules/core-js/modules/es6.set.js":{"id":119,"meta":{}},"./node_modules/core-js/modules/es6.weak-map.js":{"id":120,"meta":{}},"./node_modules/axios/index.js":{"id":121,"meta":{}},"./node_modules/babel-polyfill/lib/index.js":{"id":122,"meta":{}},"./node_modules/vue-router/dist/vue-router.esm.js":{"id":123,"meta":{"harmonyModule":true},"exports":["default"]},"./node_modules/vue/dist/vue.common.js":{"id":124,"meta":{}},"./node_modules/axios/lib/axios.js":{"id":125,"meta":{}},"./node_modules/axios/lib/cancel/CancelToken.js":{"id":126,"meta":{}},"./node_modules/axios/lib/core/Axios.js":{"id":127,"meta":{}},"./node_modules/axios/lib/core/InterceptorManager.js":{"id":128,"meta":{}},"./node_modules/axios/lib/core/dispatchRequest.js":{"id":129,"meta":{}},"./node_modules/axios/lib/core/enhanceError.js":{"id":130,"meta":{}},"./node_modules/axios/lib/core/settle.js":{"id":131,"meta":{}},"./node_modules/axios/lib/core/transformData.js":{"id":132,"meta":{}},"./node_modules/axios/lib/helpers/btoa.js":{"id":133,"meta":{}},"./node_modules/axios/lib/helpers/buildURL.js":{"id":134,"meta":{}},"./node_modules/axios/lib/helpers/combineURLs.js":{"id":135,"meta":{}},"./node_modules/axios/lib/helpers/cookies.js":{"id":136,"meta":{}},"./node_modules/axios/lib/helpers/isAbsoluteURL.js":{"id":137,"meta":{}},"./node_modules/axios/lib/helpers/isURLSameOrigin.js":{"id":138,"meta":{}},"./node_modules/axios/lib/helpers/normalizeHeaderName.js":{"id":139,"meta":{}},"./node_modules/axios/lib/helpers/parseHeaders.js":{"id":140,"meta":{}},"./node_modules/axios/lib/helpers/spread.js":{"id":141,"meta":{}},"./node_modules/core-js/fn/regexp/escape.js":{"id":142,"meta":{}},"./node_modules/core-js/modules/_array-species-constructor.js":{"id":143,"meta":{}},"./node_modules/core-js/modules/_array-species-create.js":{"id":144,"meta":{}},"./node_modules/core-js/modules/_date-to-primitive.js":{"id":145,"meta":{}},"./node_modules/core-js/modules/_enum-keys.js":{"id":146,"meta":{}},"./node_modules/core-js/modules/_keyof.js":{"id":147,"meta":{}},"./node_modules/core-js/modules/_partial.js":{"id":148,"meta":{}},"./node_modules/core-js/modules/_path.js":{"id":149,"meta":{}},"./node_modules/core-js/modules/_replacer.js":{"id":150,"meta":{}},"./node_modules/core-js/modules/core.regexp.escape.js":{"id":151,"meta":{}},"./node_modules/core-js/modules/es6.array.copy-within.js":{"id":152,"meta":{}},"./node_modules/core-js/modules/es6.array.every.js":{"id":153,"meta":{}},"./node_modules/core-js/modules/es6.array.fill.js":{"id":154,"meta":{}},"./node_modules/core-js/modules/es6.array.filter.js":{"id":155,"meta":{}},"./node_modules/core-js/modules/es6.array.find-index.js":{"id":156,"meta":{}},"./node_modules/core-js/modules/es6.array.find.js":{"id":157,"meta":{}},"./node_modules/core-js/modules/es6.array.for-each.js":{"id":158,"meta":{}},"./node_modules/core-js/modules/es6.array.from.js":{"id":159,"meta":{}},"./node_modules/core-js/modules/es6.array.index-of.js":{"id":160,"meta":{}},"./node_modules/core-js/modules/es6.array.is-array.js":{"id":161,"meta":{}},"./node_modules/core-js/modules/es6.array.join.js":{"id":162,"meta":{}},"./node_modules/core-js/modules/es6.array.last-index-of.js":{"id":163,"meta":{}},"./node_modules/core-js/modules/es6.array.map.js":{"id":164,"meta":{}},"./node_modules/core-js/modules/es6.array.of.js":{"id":165,"meta":{}},"./node_modules/core-js/modules/es6.array.reduce-right.js":{"id":166,"meta":{}},"./node_modules/core-js/modules/es6.array.reduce.js":{"id":167,"meta":{}},"./node_modules/core-js/modules/es6.array.slice.js":{"id":168,"meta":{}},"./node_modules/core-js/modules/es6.array.some.js":{"id":169,"meta":{}},"./node_modules/core-js/modules/es6.array.sort.js":{"id":170,"meta":{}},"./node_modules/core-js/modules/es6.array.species.js":{"id":171,"meta":{}},"./node_modules/core-js/modules/es6.date.now.js":{"id":172,"meta":{}},"./node_modules/core-js/modules/es6.date.to-iso-string.js":{"id":173,"meta":{}},"./node_modules/core-js/modules/es6.date.to-json.js":{"id":174,"meta":{}},"./node_modules/core-js/modules/es6.date.to-primitive.js":{"id":175,"meta":{}},"./node_modules/core-js/modules/es6.date.to-string.js":{"id":176,"meta":{}},"./node_modules/core-js/modules/es6.function.bind.js":{"id":177,"meta":{}},"./node_modules/core-js/modules/es6.function.has-instance.js":{"id":178,"meta":{}},"./node_modules/core-js/modules/es6.function.name.js":{"id":179,"meta":{}},"./node_modules/core-js/modules/es6.math.acosh.js":{"id":180,"meta":{}},"./node_modules/core-js/modules/es6.math.asinh.js":{"id":181,"meta":{}},"./node_modules/core-js/modules/es6.math.atanh.js":{"id":182,"meta":{}},"./node_modules/core-js/modules/es6.math.cbrt.js":{"id":183,"meta":{}},"./node_modules/core-js/modules/es6.math.clz32.js":{"id":184,"meta":{}},"./node_modules/core-js/modules/es6.math.cosh.js":{"id":185,"meta":{}},"./node_modules/core-js/modules/es6.math.expm1.js":{"id":186,"meta":{}},"./node_modules/core-js/modules/es6.math.fround.js":{"id":187,"meta":{}},"./node_modules/core-js/modules/es6.math.hypot.js":{"id":188,"meta":{}},"./node_modules/core-js/modules/es6.math.imul.js":{"id":189,"meta":{}},"./node_modules/core-js/modules/es6.math.log10.js":{"id":190,"meta":{}},"./node_modules/core-js/modules/es6.math.log1p.js":{"id":191,"meta":{}},"./node_modules/core-js/modules/es6.math.log2.js":{"id":192,"meta":{}},"./node_modules/core-js/modules/es6.math.sign.js":{"id":193,"meta":{}},"./node_modules/core-js/modules/es6.math.sinh.js":{"id":194,"meta":{}},"./node_modules/core-js/modules/es6.math.tanh.js":{"id":195,"meta":{}},"./node_modules/core-js/modules/es6.math.trunc.js":{"id":196,"meta":{}},"./node_modules/core-js/modules/es6.number.constructor.js":{"id":197,"meta":{}},"./node_modules/core-js/modules/es6.number.epsilon.js":{"id":198,"meta":{}},"./node_modules/core-js/modules/es6.number.is-finite.js":{"id":199,"meta":{}},"./node_modules/core-js/modules/es6.number.is-integer.js":{"id":200,"meta":{}},"./node_modules/core-js/modules/es6.number.is-nan.js":{"id":201,"meta":{}},"./node_modules/core-js/modules/es6.number.is-safe-integer.js":{"id":202,"meta":{}},"./node_modules/core-js/modules/es6.number.max-safe-integer.js":{"id":203,"meta":{}},"./node_modules/core-js/modules/es6.number.min-safe-integer.js":{"id":204,"meta":{}},"./node_modules/core-js/modules/es6.number.parse-float.js":{"id":205,"meta":{}},"./node_modules/core-js/modules/es6.number.parse-int.js":{"id":206,"meta":{}},"./node_modules/core-js/modules/es6.number.to-fixed.js":{"id":207,"meta":{}},"./node_modules/core-js/modules/es6.number.to-precision.js":{"id":208,"meta":{}},"./node_modules/core-js/modules/es6.object.assign.js":{"id":209,"meta":{}},"./node_modules/core-js/modules/es6.object.create.js":{"id":210,"meta":{}},"./node_modules/core-js/modules/es6.object.define-properties.js":{"id":211,"meta":{}},"./node_modules/core-js/modules/es6.object.define-property.js":{"id":212,"meta":{}},"./node_modules/core-js/modules/es6.object.freeze.js":{"id":213,"meta":{}},"./node_modules/core-js/modules/es6.object.get-own-property-descriptor.js":{"id":214,"meta":{}},"./node_modules/core-js/modules/es6.object.get-own-property-names.js":{"id":215,"meta":{}},"./node_modules/core-js/modules/es6.object.get-prototype-of.js":{"id":216,"meta":{}},"./node_modules/core-js/modules/es6.object.is-extensible.js":{"id":217,"meta":{}},"./node_modules/core-js/modules/es6.object.is-frozen.js":{"id":218,"meta":{}},"./node_modules/core-js/modules/es6.object.is-sealed.js":{"id":219,"meta":{}},"./node_modules/core-js/modules/es6.object.is.js":{"id":220,"meta":{}},"./node_modules/core-js/modules/es6.object.keys.js":{"id":221,"meta":{}},"./node_modules/core-js/modules/es6.object.prevent-extensions.js":{"id":222,"meta":{}},"./node_modules/core-js/modules/es6.object.seal.js":{"id":223,"meta":{}},"./node_modules/core-js/modules/es6.object.set-prototype-of.js":{"id":224,"meta":{}},"./node_modules/core-js/modules/es6.object.to-string.js":{"id":225,"meta":{}},"./node_modules/core-js/modules/es6.parse-float.js":{"id":226,"meta":{}},"./node_modules/core-js/modules/es6.parse-int.js":{"id":227,"meta":{}},"./node_modules/core-js/modules/es6.promise.js":{"id":228,"meta":{}},"./node_modules/core-js/modules/es6.reflect.apply.js":{"id":229,"meta":{}},"./node_modules/core-js/modules/es6.reflect.construct.js":{"id":230,"meta":{}},"./node_modules/core-js/modules/es6.reflect.define-property.js":{"id":231,"meta":{}},"./node_modules/core-js/modules/es6.reflect.delete-property.js":{"id":232,"meta":{}},"./node_modules/core-js/modules/es6.reflect.enumerate.js":{"id":233,"meta":{}},"./node_modules/core-js/modules/es6.reflect.get-own-property-descriptor.js":{"id":234,"meta":{}},"./node_modules/core-js/modules/es6.reflect.get-prototype-of.js":{"id":235,"meta":{}},"./node_modules/core-js/modules/es6.reflect.get.js":{"id":236,"meta":{}},"./node_modules/core-js/modules/es6.reflect.has.js":{"id":237,"meta":{}},"./node_modules/core-js/modules/es6.reflect.is-extensible.js":{"id":238,"meta":{}},"./node_modules/core-js/modules/es6.reflect.own-keys.js":{"id":239,"meta":{}},"./node_modules/core-js/modules/es6.reflect.prevent-extensions.js":{"id":240,"meta":{}},"./node_modules/core-js/modules/es6.reflect.set-prototype-of.js":{"id":241,"meta":{}},"./node_modules/core-js/modules/es6.reflect.set.js":{"id":242,"meta":{}},"./node_modules/core-js/modules/es6.regexp.constructor.js":{"id":243,"meta":{}},"./node_modules/core-js/modules/es6.regexp.match.js":{"id":244,"meta":{}},"./node_modules/core-js/modules/es6.regexp.replace.js":{"id":245,"meta":{}},"./node_modules/core-js/modules/es6.regexp.search.js":{"id":246,"meta":{}},"./node_modules/core-js/modules/es6.regexp.split.js":{"id":247,"meta":{}},"./node_modules/core-js/modules/es6.regexp.to-string.js":{"id":248,"meta":{}},"./node_modules/core-js/modules/es6.string.anchor.js":{"id":249,"meta":{}},"./node_modules/core-js/modules/es6.string.big.js":{"id":250,"meta":{}},"./node_modules/core-js/modules/es6.string.blink.js":{"id":251,"meta":{}},"./node_modules/core-js/modules/es6.string.bold.js":{"id":252,"meta":{}},"./node_modules/core-js/modules/es6.string.code-point-at.js":{"id":253,"meta":{}},"./node_modules/core-js/modules/es6.string.ends-with.js":{"id":254,"meta":{}},"./node_modules/core-js/modules/es6.string.fixed.js":{"id":255,"meta":{}},"./node_modules/core-js/modules/es6.string.fontcolor.js":{"id":256,"meta":{}},"./node_modules/core-js/modules/es6.string.fontsize.js":{"id":257,"meta":{}},"./node_modules/core-js/modules/es6.string.from-code-point.js":{"id":258,"meta":{}},"./node_modules/core-js/modules/es6.string.includes.js":{"id":259,"meta":{}},"./node_modules/core-js/modules/es6.string.italics.js":{"id":260,"meta":{}},"./node_modules/core-js/modules/es6.string.iterator.js":{"id":261,"meta":{}},"./node_modules/core-js/modules/es6.string.link.js":{"id":262,"meta":{}},"./node_modules/core-js/modules/es6.string.raw.js":{"id":263,"meta":{}},"./node_modules/core-js/modules/es6.string.repeat.js":{"id":264,"meta":{}},"./node_modules/core-js/modules/es6.string.small.js":{"id":265,"meta":{}},"./node_modules/core-js/modules/es6.string.starts-with.js":{"id":266,"meta":{}},"./node_modules/core-js/modules/es6.string.strike.js":{"id":267,"meta":{}},"./node_modules/core-js/modules/es6.string.sub.js":{"id":268,"meta":{}},"./node_modules/core-js/modules/es6.string.sup.js":{"id":269,"meta":{}},"./node_modules/core-js/modules/es6.string.trim.js":{"id":270,"meta":{}},"./node_modules/core-js/modules/es6.symbol.js":{"id":271,"meta":{}},"./node_modules/core-js/modules/es6.typed.array-buffer.js":{"id":272,"meta":{}},"./node_modules/core-js/modules/es6.typed.data-view.js":{"id":273,"meta":{}},"./node_modules/core-js/modules/es6.typed.float32-array.js":{"id":274,"meta":{}},"./node_modules/core-js/modules/es6.typed.float64-array.js":{"id":275,"meta":{}},"./node_modules/core-js/modules/es6.typed.int16-array.js":{"id":276,"meta":{}},"./node_modules/core-js/modules/es6.typed.int32-array.js":{"id":277,"meta":{}},"./node_modules/core-js/modules/es6.typed.int8-array.js":{"id":278,"meta":{}},"./node_modules/core-js/modules/es6.typed.uint16-array.js":{"id":279,"meta":{}},"./node_modules/core-js/modules/es6.typed.uint32-array.js":{"id":280,"meta":{}},"./node_modules/core-js/modules/es6.typed.uint8-array.js":{"id":281,"meta":{}},"./node_modules/core-js/modules/es6.typed.uint8-clamped-array.js":{"id":282,"meta":{}},"./node_modules/core-js/modules/es6.weak-set.js":{"id":283,"meta":{}},"./node_modules/core-js/modules/es7.array.includes.js":{"id":284,"meta":{}},"./node_modules/core-js/modules/es7.asap.js":{"id":285,"meta":{}},"./node_modules/core-js/modules/es7.error.is-error.js":{"id":286,"meta":{}},"./node_modules/core-js/modules/es7.map.to-json.js":{"id":287,"meta":{}},"./node_modules/core-js/modules/es7.math.iaddh.js":{"id":288,"meta":{}},"./node_modules/core-js/modules/es7.math.imulh.js":{"id":289,"meta":{}},"./node_modules/core-js/modules/es7.math.isubh.js":{"id":290,"meta":{}},"./node_modules/core-js/modules/es7.math.umulh.js":{"id":291,"meta":{}},"./node_modules/core-js/modules/es7.object.define-getter.js":{"id":292,"meta":{}},"./node_modules/core-js/modules/es7.object.define-setter.js":{"id":293,"meta":{}},"./node_modules/core-js/modules/es7.object.entries.js":{"id":294,"meta":{}},"./node_modules/core-js/modules/es7.object.get-own-property-descriptors.js":{"id":295,"meta":{}},"./node_modules/core-js/modules/es7.object.lookup-getter.js":{"id":296,"meta":{}},"./node_modules/core-js/modules/es7.object.lookup-setter.js":{"id":297,"meta":{}},"./node_modules/core-js/modules/es7.object.values.js":{"id":298,"meta":{}},"./node_modules/core-js/modules/es7.observable.js":{"id":299,"meta":{}},"./node_modules/core-js/modules/es7.reflect.define-metadata.js":{"id":300,"meta":{}},"./node_modules/core-js/modules/es7.reflect.delete-metadata.js":{"id":301,"meta":{}},"./node_modules/core-js/modules/es7.reflect.get-metadata-keys.js":{"id":302,"meta":{}},"./node_modules/core-js/modules/es7.reflect.get-metadata.js":{"id":303,"meta":{}},"./node_modules/core-js/modules/es7.reflect.get-own-metadata-keys.js":{"id":304,"meta":{}},"./node_modules/core-js/modules/es7.reflect.get-own-metadata.js":{"id":305,"meta":{}},"./node_modules/core-js/modules/es7.reflect.has-metadata.js":{"id":306,"meta":{}},"./node_modules/core-js/modules/es7.reflect.has-own-metadata.js":{"id":307,"meta":{}},"./node_modules/core-js/modules/es7.reflect.metadata.js":{"id":308,"meta":{}},"./node_modules/core-js/modules/es7.set.to-json.js":{"id":309,"meta":{}},"./node_modules/core-js/modules/es7.string.at.js":{"id":310,"meta":{}},"./node_modules/core-js/modules/es7.string.match-all.js":{"id":311,"meta":{}},"./node_modules/core-js/modules/es7.string.pad-end.js":{"id":312,"meta":{}},"./node_modules/core-js/modules/es7.string.pad-start.js":{"id":313,"meta":{}},"./node_modules/core-js/modules/es7.string.trim-left.js":{"id":314,"meta":{}},"./node_modules/core-js/modules/es7.string.trim-right.js":{"id":315,"meta":{}},"./node_modules/core-js/modules/es7.symbol.async-iterator.js":{"id":316,"meta":{}},"./node_modules/core-js/modules/es7.symbol.observable.js":{"id":317,"meta":{}},"./node_modules/core-js/modules/es7.system.global.js":{"id":318,"meta":{}},"./node_modules/core-js/modules/web.dom.iterable.js":{"id":319,"meta":{}},"./node_modules/core-js/modules/web.immediate.js":{"id":320,"meta":{}},"./node_modules/core-js/modules/web.timers.js":{"id":321,"meta":{}},"./node_modules/core-js/shim.js":{"id":322,"meta":{}},"./node_modules/process/browser.js":{"id":323,"meta":{}},"./node_modules/regenerator-runtime/runtime.js":{"id":324,"meta":{}}}} \ No newline at end of file diff --git a/build/vue-loader.conf.js b/build/vue-loader.conf.js index a86af01c9e2aa2bb5814bf0c51a70b928c53311d..33ed58bc0afcb7e28e81762dea765aca5d47b801 100644 --- a/build/vue-loader.conf.js +++ b/build/vue-loader.conf.js @@ -1,17 +1,22 @@ -var utils = require('./utils') -var config = require('../config') -var isProduction = process.env.NODE_ENV === 'production' +'use strict' +const utils = require('./utils') +const config = require('../config') +const isProduction = process.env.NODE_ENV === 'production' +const sourceMapEnabled = isProduction + ? config.build.productionSourceMap + : config.dev.cssSourceMap module.exports = { loaders: utils.cssLoaders({ - sourceMap: isProduction - ? config.build.productionSourceMap - : config.dev.cssSourceMap, + sourceMap: sourceMapEnabled, extract: isProduction }), - postcss: [ - require('autoprefixer')({ - browsers: ['last 2 versions'] - }) - ] + cssSourceMap: sourceMapEnabled, + cacheBusting: config.dev.cacheBusting, + transformToRequire: { + video: ['src', 'poster'], + source: 'src', + img: 'src', + image: 'xlink:href' + } } diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 213229014ef8d7b30fcec587e850ecb2dd2dfe6a..98afe286626b9879161c722dd2e7dd15c00f5cca 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -1,16 +1,19 @@ -var path = require('path') -var utils = require('./utils') -var webpack = require('webpack') -var config = require('../config') -var vueLoaderConfig = require('./vue-loader.conf') +'use strict' +const path = require('path') +const utils = require('./utils') +const config = require('../config') +const vueLoaderConfig = require('./vue-loader.conf') function resolve (dir) { return path.join(__dirname, '..', dir) } + + module.exports = { + context: path.resolve(__dirname, '../'), entry: { - app: ['babel-polyfill','./src/main.js'] + app: './src/main.js' }, output: { path: config.build.assetsRoot, @@ -21,22 +24,18 @@ module.exports = { }, resolve: { extensions: ['.js', '.vue', '.json'], - modules: [ - resolve('src'), - resolve('node_modules') - ], alias: { - 'vue$': 'vue/dist/vue.common.js', - 'src': resolve('src'), - 'assets': resolve('src/assets'), - 'components': resolve('src/components') + 'vue$': 'vue/dist/vue.esm.js', + '@': resolve('src'), + 'static': path.resolve(__dirname, '../static'), } }, module: { rules: [ { test: /\.vue$/, - loader: 'vue-loader' + loader: 'vue-loader', + options: vueLoaderConfig }, { test: /\.js$/, @@ -46,25 +45,39 @@ module.exports = { { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url-loader', - query: { + options: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, + { + test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, + loader: 'url-loader', + options: { + limit: 10000, + name: utils.assetsPath('media/[name].[hash:7].[ext]') + } + }, { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, loader: 'url-loader', - query: { + options: { limit: 10000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } } ] }, - // plugins: [ - // new webpack.DllReferencePlugin({ - // context: path.resolve(__dirname, '..'), - // manifest: require('./vendor-manifest.json') - // }) - // ] + node: { + // prevent webpack from injecting useless setImmediate polyfill because Vue + // source contains it (although only uses it if it's native). + setImmediate: false, + // prevent webpack from injecting mocks to Node native modules + // that does not make sense for the client + dgram: 'empty', + fs: 'empty', + net: 'empty', + tls: 'empty', + child_process: 'empty' + } } diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 5470402d0377c4c399febfc48aa6b3585e33c6a2..03e94282ba2b3682322422f8c9b7e48e40e842f7 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -1,28 +1,48 @@ -var utils = require('./utils') -var webpack = require('webpack') -var config = require('../config') -var merge = require('webpack-merge') -var baseWebpackConfig = require('./webpack.base.conf') -var HtmlWebpackPlugin = require('html-webpack-plugin') -var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') +'use strict' +const utils = require('./utils') +const webpack = require('webpack') +const config = require('../config') +const merge = require('webpack-merge') +const baseWebpackConfig = require('./webpack.base.conf') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') +const portfinder = require('portfinder') -// add hot-reload related code to entry chunks -Object.keys(baseWebpackConfig.entry).forEach(function (name) { - baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) -}) +const HOST = process.env.HOST +const PORT = process.env.PORT && Number(process.env.PORT) -module.exports = merge(baseWebpackConfig, { +const devWebpackConfig = merge(baseWebpackConfig, { module: { - rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) + rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) }, // cheap-module-eval-source-map is faster for development - devtool: '#cheap-module-eval-source-map', + devtool: config.dev.devtool, + + // these devServer options should be customized in /config/index.js + devServer: { + clientLogLevel: 'warning', + historyApiFallback: true, + hot: true, + compress: true, + host: HOST || config.dev.host, + port: PORT || config.dev.port, + open: config.dev.autoOpenBrowser, + overlay: config.dev.errorOverlay + ? { warnings: false, errors: true } + : false, + publicPath: config.dev.assetsPublicPath, + proxy: config.dev.proxyTable, + quiet: true, // necessary for FriendlyErrorsPlugin + watchOptions: { + poll: config.dev.poll, + } + }, plugins: [ new webpack.DefinePlugin({ - 'process.env': config.dev.env + 'process.env': require('../config/dev.env') }), - // https://github.com/glenjamin/webpack-hot-middleware#installation--usage new webpack.HotModuleReplacementPlugin(), + new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. new webpack.NoEmitOnErrorsPlugin(), // https://github.com/ampedandwired/html-webpack-plugin new HtmlWebpackPlugin({ @@ -30,6 +50,31 @@ module.exports = merge(baseWebpackConfig, { template: 'index.html', inject: true }), - new FriendlyErrorsPlugin() ] }) + +module.exports = new Promise((resolve, reject) => { + portfinder.basePort = process.env.PORT || config.dev.port + portfinder.getPort((err, port) => { + if (err) { + reject(err) + } else { + // publish the new Port, necessary for e2e tests + process.env.PORT = port + // add port to devServer config + devWebpackConfig.devServer.port = port + + // Add FriendlyErrorsPlugin + devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ + compilationSuccessInfo: { + messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], + }, + onErrors: config.dev.notifyOnErrors + ? utils.createNotifierCallback() + : undefined + })) + + resolve(devWebpackConfig) + } + }) +}) diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 1cc4432bb7b1f112da5b35a5a209b8ff3be798d1..5b53b9a0eff88884946277330ddf8a54118f1c60 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -1,21 +1,27 @@ -var path = require('path') -var utils = require('./utils') -var webpack = require('webpack') -var config = require('../config') -var merge = require('webpack-merge') -var baseWebpackConfig = require('./webpack.base.conf') -var HtmlWebpackPlugin = require('html-webpack-plugin') -var ExtractTextPlugin = require('extract-text-webpack-plugin') -var env = config.build.env +'use strict' +const path = require('path') +const utils = require('./utils') +const webpack = require('webpack') +const config = require('../config') +const merge = require('webpack-merge') +const baseWebpackConfig = require('./webpack.base.conf') +const CopyWebpackPlugin = require('copy-webpack-plugin') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') +const UglifyJsPlugin = require('uglifyjs-webpack-plugin') -var webpackConfig = merge(baseWebpackConfig, { +const env = require('../config/prod.env') + +const webpackConfig = merge(baseWebpackConfig, { module: { rules: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, - extract: true + extract: true, + usePostCSS: true }) }, - devtool: config.build.productionSourceMap ? '#source-map' : false, + devtool: config.build.productionSourceMap ? config.build.devtool : false, output: { path: config.build.assetsRoot, filename: utils.assetsPath('js/[name].[chunkhash].js'), @@ -26,15 +32,30 @@ var webpackConfig = merge(baseWebpackConfig, { new webpack.DefinePlugin({ 'process.env': env }), - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false + new UglifyJsPlugin({ + uglifyOptions: { + compress: { + warnings: false + } }, - sourceMap: true + sourceMap: config.build.productionSourceMap, + parallel: true }), // extract css into its own file new ExtractTextPlugin({ - filename: utils.assetsPath('css/[name].[contenthash].css') + filename: utils.assetsPath('css/[name].[contenthash].css'), + // Setting the following option to `false` will not extract CSS from codesplit chunks. + // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. + // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, + // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 + allChunks: true, + }), + // Compress extracted CSS. We are using this plugin so that possible + // duplicated CSS from different components can be deduped. + new OptimizeCSSPlugin({ + cssProcessorOptions: config.build.productionSourceMap + ? { safe: true, map: { inline: false } } + : { safe: true } }), // generate dist index.html with correct asset hash for caching. // you can customize output by editing /index.html @@ -53,10 +74,14 @@ var webpackConfig = merge(baseWebpackConfig, { // necessary to consistently work with multiple chunks via CommonsChunkPlugin chunksSortMode: 'dependency' }), + // keep module.id stable when vender modules does not change + new webpack.HashedModuleIdsPlugin(), + // enable scope hoisting + new webpack.optimize.ModuleConcatenationPlugin(), // split vendor js into its own file new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', - minChunks: function (module, count) { + minChunks (module) { // any required modules inside node_modules are extracted to vendor return ( module.resource && @@ -71,13 +96,31 @@ var webpackConfig = merge(baseWebpackConfig, { // prevent vendor hash from being updated whenever app bundle is updated new webpack.optimize.CommonsChunkPlugin({ name: 'manifest', - chunks: ['vendor'] - }) + minChunks: Infinity + }), + // This instance extracts shared chunks from code splitted chunks and bundles them + // in a separate chunk, similar to the vendor chunk + // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk + new webpack.optimize.CommonsChunkPlugin({ + name: 'app', + async: 'vendor-async', + children: true, + minChunks: 3 + }), + + // copy custom static assets + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, '../static'), + to: config.build.assetsSubDirectory, + ignore: ['.*'] + } + ]) ] }) if (config.build.productionGzip) { - var CompressionWebpackPlugin = require('compression-webpack-plugin') + const CompressionWebpackPlugin = require('compression-webpack-plugin') webpackConfig.plugins.push( new CompressionWebpackPlugin({ @@ -95,7 +138,7 @@ if (config.build.productionGzip) { } if (config.build.bundleAnalyzerReport) { - var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin + const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin webpackConfig.plugins.push(new BundleAnalyzerPlugin()) } diff --git a/config/dev.env.js b/config/dev.env.js index efead7c840a15f2a06ed28fcf1304293a9b704e0..1e22973ae71e949faa15f7a8ab392786918fb22d 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -1,5 +1,6 @@ -var merge = require('webpack-merge') -var prodEnv = require('./prod.env') +'use strict' +const merge = require('webpack-merge') +const prodEnv = require('./prod.env') module.exports = merge(prodEnv, { NODE_ENV: '"development"' diff --git a/config/index.js b/config/index.js index b501c69932d99a1d58ea520d646a3470b125f5b2..b8e6882598d0d37b850e28708134142aa3161791 100644 --- a/config/index.js +++ b/config/index.js @@ -1,50 +1,85 @@ +'use strict' +// Template version: 1.2.7 // see http://vuejs-templates.github.io/webpack for documentation. -var path = require('path') + +const path = require('path') module.exports = { - build: { - env: require('./prod.env'), - index: path.resolve(__dirname, '../dist/index.html'), - assetsRoot: path.resolve(__dirname, '../dist'), - assetsSubDirectory: 'static', - assetsPublicPath: './', - productionSourceMap: false, - // Gzip off by default as many popular static hosts such as - // Surge or Netlify already gzip all static assets for you. - // Before setting to `true`, make sure to: - // npm install --save-dev compression-webpack-plugin - productionGzip: false, - productionGzipExtensions: ['js', 'css'], - // Run the build command with an extra argument to - // View the bundle analyzer report after build finishes: - // `npm run build --report` - // Set to `true` or `false` to always turn it on or off - bundleAnalyzerReport: process.env.npm_config_report + dev: { + + // Paths + assetsSubDirectory: 'static', + assetsPublicPath: '/', + proxyTable: { + '/api':{ + target:'http://jsonplaceholder.typicode.com', + changeOrigin:true, + pathRewrite:{ + '/api':'' + } + }, + '/ms':{ + target: 'https://www.easy-mock.com/mock/592501a391470c0ac1fab128', + changeOrigin: true + } }, - dev: { - env: require('./dev.env'), - port: 8080, - autoOpenBrowser: true, - assetsSubDirectory: 'static', - assetsPublicPath: '/', - proxyTable: { - '/api':{ - target:'http://jsonplaceholder.typicode.com', - changeOrigin:true, - pathRewrite:{ - '/api':'' - } - }, - '/ms':{ - target: 'https://www.easy-mock.com/mock/592501a391470c0ac1fab128', - changeOrigin: true - } - }, - // CSS Sourcemaps off by default because relative paths are "buggy" - // with this option, according to the CSS-Loader README - // (https://github.com/webpack/css-loader#sourcemaps) - // In our experience, they generally work as expected, - // just be aware of this issue when enabling this option. - cssSourceMap: false - } + // Various Dev Server settings + host: 'localhost', // can be overwritten by process.env.HOST + port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined + autoOpenBrowser: false, + errorOverlay: true, + notifyOnErrors: true, + poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- + + + /** + * Source Maps + */ + + // https://webpack.js.org/configuration/devtool/#development + devtool: 'eval-source-map', + + // If you have problems debugging vue-files in devtools, + // set this to false - it *may* help + // https://vue-loader.vuejs.org/en/options.html#cachebusting + cacheBusting: true, + + // CSS Sourcemaps off by default because relative paths are "buggy" + // with this option, according to the CSS-Loader README + // (https://github.com/webpack/css-loader#sourcemaps) + // In our experience, they generally work as expected, + // just be aware of this issue when enabling this option. + cssSourceMap: false, + }, + + build: { + // Template for index.html + index: path.resolve(__dirname, '../dist/index.html'), + + // Paths + assetsRoot: path.resolve(__dirname, '../dist'), + assetsSubDirectory: 'static', + assetsPublicPath: './', + + /** + * Source Maps + */ + + productionSourceMap: true, + // https://webpack.js.org/configuration/devtool/#production + devtool: '#source-map', + + // Gzip off by default as many popular static hosts such as + // Surge or Netlify already gzip all static assets for you. + // Before setting to `true`, make sure to: + // npm install --save-dev compression-webpack-plugin + productionGzip: false, + productionGzipExtensions: ['js', 'css'], + + // Run the build command with an extra argument to + // View the bundle analyzer report after build finishes: + // `npm run build --report` + // Set to `true` or `false` to always turn it on or off + bundleAnalyzerReport: process.env.npm_config_report + } } diff --git a/config/prod.env.js b/config/prod.env.js index 773d263d31260be27d2d7e3fbaa5c17ae4e732f6..a6f997616eff680e4b2d437e7f31de2cadbfa1de 100644 --- a/config/prod.env.js +++ b/config/prod.env.js @@ -1,3 +1,4 @@ +'use strict' module.exports = { NODE_ENV: '"production"' } diff --git a/package.json b/package.json index 9b31bbcda623e28beb1c62881f90914f23b3b105..0f040c6369770f833a265ca513b74f910a58f609 100644 --- a/package.json +++ b/package.json @@ -1,57 +1,60 @@ { - "name": "manage-system", - "version": "2.1.0", + "name": "vue-manage-system", + "version": "3.0.0", "description": "基于Vue.js 2.x系列 + element-ui 内容管理系统解决方案", "author": "lin-xin <2981207131@qq.com>", "private": true, "scripts": { - "dev": "node build/dev-server.js", + "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "build": "node build/build.js", "build:dll": "webpack --config build/webpack.dll.conf.js" }, "dependencies": { "axios": "^0.15.3", "babel-polyfill": "^6.23.0", - "element-ui": "1.3.1", - "vue": "^2.3.2", + "element-ui": "2.3.3", + "vue": "^2.5.16", "vue-core-image-upload": "2.1.11", - "vue-datasource": "1.0.9", - "vue-quill-editor": "2.1.6", - "vue-router": "^2.3.1", - "vue-schart": "^0.1.2", - "vue-simplemde": "0.3.8" + "vue-datasource": "1.0.12", + "vue-quill-editor": "3.0.6", + "vue-router": "^3.0.1", + "vue-schart": "^0.1.4" }, "devDependencies": { - "autoprefixer": "^6.7.2", + "autoprefixer": "^7.1.2", "babel-core": "^6.22.1", - "babel-loader": "^6.2.10", + "babel-helper-vue-jsx-merge-props": "^2.0.3", + "babel-loader": "^7.1.1", + "babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-transform-runtime": "^6.22.0", - "babel-preset-es2015": "^6.22.0", + "babel-plugin-transform-vue-jsx": "^3.5.0", + "babel-preset-env": "^1.3.2", + "babel-preset-es2015": "^6.24.1", "babel-preset-stage-2": "^6.22.0", - "babel-register": "^6.22.0", - "chalk": "^1.1.3", - "connect-history-api-fallback": "^1.3.0", + "chalk": "^2.0.1", + "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.28.0", - "eventsource-polyfill": "^0.9.6", - "express": "^4.14.1", - "extract-text-webpack-plugin": "^2.0.0", - "file-loader": "^0.11.1", - "friendly-errors-webpack-plugin": "^1.1.3", - "function-bind": "^1.1.0", - "html-webpack-plugin": "^2.28.0", - "http-proxy-middleware": "^0.17.3", - "opn": "^4.0.2", + "extract-text-webpack-plugin": "^3.0.0", + "file-loader": "^1.1.4", + "friendly-errors-webpack-plugin": "^1.6.1", + "html-webpack-plugin": "^2.30.1", + "node-notifier": "^5.1.2", + "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^1.2.0", + "portfinder": "^1.0.13", + "postcss-import": "^11.0.0", + "postcss-loader": "^2.0.8", + "rimraf": "^2.6.0", "semver": "^5.3.0", "shelljs": "^0.7.6", + "uglifyjs-webpack-plugin": "^1.1.1", "url-loader": "^0.5.8", - "vue-loader": "^11.3.4", - "vue-style-loader": "^2.0.5", - "vue-template-compiler": "^2.2.6", - "webpack": "^2.3.3", - "webpack-bundle-analyzer": "^2.2.1", - "webpack-dev-middleware": "^1.10.0", - "webpack-hot-middleware": "^2.18.0", + "vue-loader": "^13.3.0", + "vue-style-loader": "^3.0.1", + "vue-template-compiler": "^2.5.2", + "webpack": "^3.6.0", + "webpack-bundle-analyzer": "^2.9.0", + "webpack-dev-server": "^2.9.1", "webpack-merge": "^4.1.0" }, "engines": { diff --git a/src/components/common/Sidebar.vue b/src/components/common/Sidebar.vue index be9ee8e5c13401c0386345dd409ac4746e69e708..a2c94b46b1842d415bd0a28331255c54792bb028 100644 --- a/src/components/common/Sidebar.vue +++ b/src/components/common/Sidebar.vue @@ -1,16 +1,20 @@