diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 070ae22..af58bf9 100755 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -1,21 +1,21 @@ -'use strict' -const utils = require('./utils') -const webpack = require('webpack') -const config = require('../config') -const merge = require('webpack-merge') -const path = require('path') -const baseWebpackConfig = require('./webpack.base.conf') -const CopyWebpackPlugin = require('copy-webpack-plugin') -const HtmlWebpackPlugin = require('html-webpack-plugin') -const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') -const portfinder = require('portfinder') +'use strict'; +const utils = require('./utils'); +const webpack = require('webpack'); +const config = require('../config'); +const merge = require('webpack-merge'); +const path = require('path'); +const baseWebpackConfig = require('./webpack.base.conf'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); +const portfinder = require('portfinder'); -const HOST = process.env.HOST -const PORT = process.env.PORT && Number(process.env.PORT) +const HOST = process.env.HOST; +const PORT = process.env.PORT && Number(process.env.PORT); const devWebpackConfig = merge(baseWebpackConfig, { module: { - rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) + rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }), }, // cheap-module-eval-source-map is faster for development devtool: config.dev.devtool, @@ -24,9 +24,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { devServer: { clientLogLevel: 'warning', historyApiFallback: { - rewrites: [ - { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, - ], + rewrites: [{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }], }, hot: true, contentBase: false, // since we use CopyWebpackPlugin. @@ -34,19 +32,17 @@ const devWebpackConfig = merge(baseWebpackConfig, { host: HOST || config.dev.host, port: PORT || config.dev.port, open: config.dev.autoOpenBrowser, - overlay: config.dev.errorOverlay - ? { warnings: false, errors: true } - : false, + 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': require('../config/dev.env') + 'process.env': require('../config/dev.env'), }), new webpack.HotModuleReplacementPlugin(), new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. @@ -54,42 +50,49 @@ const devWebpackConfig = merge(baseWebpackConfig, { // https://github.com/ampedandwired/html-webpack-plugin new HtmlWebpackPlugin({ filename: 'index.html', - template: 'index.html', - inject: true + template: 'public/index.html', + inject: true, }), // copy custom static assets new CopyWebpackPlugin([ { from: path.resolve(__dirname, '../static'), to: config.dev.assetsSubDirectory, - ignore: ['.*'] - } - ]) - ] -}) + ignore: ['.*'], + }, + { + from: path.resolve(__dirname, '../public'), + to: 'public', + ignore: ['*.html'], + }, + ]), + ], +}); module.exports = new Promise((resolve, reject) => { - portfinder.basePort = process.env.PORT || config.dev.port + portfinder.basePort = process.env.PORT || config.dev.port; portfinder.getPort((err, port) => { if (err) { - reject(err) + reject(err); } else { // publish the new Port, necessary for e2e tests - process.env.PORT = port + process.env.PORT = port; // add port to devServer config - devWebpackConfig.devServer.port = port + 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 - })) + 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) + resolve(devWebpackConfig); } - }) -}) + }); +}); diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index d9f99f6..08a1a3f 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -1,52 +1,52 @@ -'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') +'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'); -const env = require('../config/prod.env') +const env = require('../config/prod.env'); const webpackConfig = merge(baseWebpackConfig, { module: { rules: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true, - usePostCSS: true - }) + usePostCSS: true, + }), }, devtool: config.build.productionSourceMap ? config.build.devtool : false, output: { path: config.build.assetsRoot, filename: utils.assetsPath('js/[name].[chunkhash].js'), - chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') + chunkFilename: utils.assetsPath('js/[id].[chunkhash].js'), }, plugins: [ // http://vuejs.github.io/vue-loader/en/workflow/production.html new webpack.DefinePlugin({ - 'process.env': env + 'process.env': env, }), new UglifyJsPlugin({ uglifyOptions: { compress: { - warnings: false - } + warnings: false, + }, }, sourceMap: config.build.productionSourceMap, - parallel: true + parallel: true, }), // extract css into its own file new ExtractTextPlugin({ 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`, + // 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, }), @@ -55,24 +55,24 @@ const webpackConfig = merge(baseWebpackConfig, { new OptimizeCSSPlugin({ cssProcessorOptions: config.build.productionSourceMap ? { safe: true, map: { inline: false } } - : { safe: true } + : { safe: true }, }), // generate dist index.html with correct asset hash for caching. // you can customize output by editing /index.html // see https://github.com/ampedandwired/html-webpack-plugin new HtmlWebpackPlugin({ filename: config.build.index, - template: 'index.html', + template: 'public/index.html', inject: true, minify: { removeComments: true, collapseWhitespace: true, - removeAttributeQuotes: true + removeAttributeQuotes: true, // more options: // https://github.com/kangax/html-minifier#options-quick-reference }, // necessary to consistently work with multiple chunks via CommonsChunkPlugin - chunksSortMode: 'dependency' + chunksSortMode: 'dependency', }), // keep module.id stable when vendor modules does not change new webpack.HashedModuleIdsPlugin(), @@ -81,22 +81,20 @@ const webpackConfig = merge(baseWebpackConfig, { // split vendor js into its own file new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', - minChunks (module) { + minChunks(module) { // any required modules inside node_modules are extracted to vendor return ( module.resource && /\.js$/.test(module.resource) && - module.resource.indexOf( - path.join(__dirname, '../node_modules') - ) === 0 - ) - } + module.resource.indexOf(path.join(__dirname, '../node_modules')) === 0 + ); + }, }), // extract webpack runtime and module manifest to its own file in order to // prevent vendor hash from being updated whenever app bundle is updated new webpack.optimize.CommonsChunkPlugin({ name: 'manifest', - minChunks: Infinity + minChunks: Infinity, }), // This instance extracts shared chunks from code splitted chunks and bundles them // in a separate chunk, similar to the vendor chunk @@ -105,7 +103,7 @@ const webpackConfig = merge(baseWebpackConfig, { name: 'app', async: 'vendor-async', children: true, - minChunks: 3 + minChunks: 3, }), // copy custom static assets @@ -113,33 +111,34 @@ const webpackConfig = merge(baseWebpackConfig, { { from: path.resolve(__dirname, '../static'), to: config.build.assetsSubDirectory, - ignore: ['.*'] - } - ]) - ] -}) + ignore: ['.*'], + }, + { + from: path.resolve(__dirname, '../public'), + to: 'public', + ignore: ['*.html'], + }, + ]), + ], +}); if (config.build.productionGzip) { - const CompressionWebpackPlugin = require('compression-webpack-plugin') + const CompressionWebpackPlugin = require('compression-webpack-plugin'); webpackConfig.plugins.push( new CompressionWebpackPlugin({ asset: '[path].gz[query]', algorithm: 'gzip', - test: new RegExp( - '\\.(' + - config.build.productionGzipExtensions.join('|') + - ')$' - ), + test: new RegExp('\\.(' + config.build.productionGzipExtensions.join('|') + ')$'), threshold: 10240, - minRatio: 0.8 + minRatio: 0.8, }) - ) + ); } if (config.build.bundleAnalyzerReport) { - const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin - webpackConfig.plugins.push(new BundleAnalyzerPlugin()) + const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; + webpackConfig.plugins.push(new BundleAnalyzerPlugin()); } -module.exports = webpackConfig +module.exports = webpackConfig; diff --git a/index.html b/index.html deleted file mode 100644 index fca2c4b..0000000 --- a/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - -
- - -