diff --git a/README.md b/README.md index e9b3f6d..4bb7ccd 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ npm run buildcdn && open dist/index.cdn.html ``` * CDN ``` - - + + ``` ## Build Setup @@ -29,9 +29,6 @@ npm run build # build for production and view the bundle analyzer report npm run build --report -# build for production support browser -npm run buildcdn - # run unit tests npm run unit diff --git a/build/build.cdn.js b/build/build.cdn.js deleted file mode 100644 index 2941f64..0000000 --- a/build/build.cdn.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict' -require('./check-versions')() - -process.env.NODE_ENV = 'cdn' - -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.cdn.conf') - -const spinner = ora('building for cdn...') -spinner.start() - -rm(path.join(config.cdn.assetsRoot, config.cdn.assetsSubDirectory), err => { - if (err) throw err - 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' - )) - }) -}) diff --git a/build/build.js b/build/build.js index 8f2ad8a..2ab5319 100644 --- a/build/build.js +++ b/build/build.js @@ -11,7 +11,7 @@ const webpack = require('webpack') const config = require('../config') const webpackConfig = require('./webpack.prod.conf') -const spinner = ora('building for production...') +const spinner = ora('building ...') spinner.start() rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { diff --git a/build/logo.png b/build/logo.png deleted file mode 100644 index f3d2503..0000000 Binary files a/build/logo.png and /dev/null differ diff --git a/build/utils.js b/build/utils.js index 79bf9dc..42be615 100644 --- a/build/utils.js +++ b/build/utils.js @@ -5,7 +5,7 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin') const packageConfig = require('../package.json') exports.assetsPath = function (_path) { - const assetsSubDirectory = (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'cdn') + const assetsSubDirectory = process.env.NODE_ENV === 'production' ? config.build.assetsSubDirectory : config.dev.assetsSubDirectory @@ -94,8 +94,7 @@ exports.createNotifierCallback = () => { notifier.notify({ title: packageConfig.name, message: severity + ': ' + error.name, - subtitle: filename || '', - icon: path.join(__dirname, 'logo.png') + subtitle: filename || '' }) } } diff --git a/build/webpack.cdn.conf.js b/build/webpack.cdn.conf.js deleted file mode 100644 index b91cdd4..0000000 --- a/build/webpack.cdn.conf.js +++ /dev/null @@ -1,87 +0,0 @@ -'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 = process.env.NODE_ENV === 'testing' - ? require('../config/test.env') - : require('../config/cdn.env') - -const webpackConfig = merge(baseWebpackConfig, { - module: { - rules: utils.styleLoaders({ - sourceMap: config.cdn.cdnSourceMap, - extract: true, - usePostCSS: true - }) - }, - devtool: config.cdn.cdnSourceMap ? config.cdn.devtool : false, - output: { - path: config.cdn.assetsRoot, - filename: utils.assetsPath('js/[name].cdn.js'), - library: 'VueCSV', - libraryTarget: 'umd' - }, - externals: { - 'vue': 'Vue' - }, - plugins: [ - // http://vuejs.github.io/vue-loader/en/workflow/production.html - new webpack.DefinePlugin({ - 'process.env': env - }), - new UglifyJsPlugin({ - uglifyOptions: { - compress: { - warnings: false - } - }, - sourceMap: config.cdn.cdnSourceMap, - parallel: true - }), - // extract css into its own file - new ExtractTextPlugin({ - filename: utils.assetsPath('css/[name].cdn.css'), - 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.cdn.cdnSourceMap - ? { 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 - // see https://github.com/ampedandwired/html-webpack-plugin - new HtmlWebpackPlugin({ - filename: process.env.NODE_ENV === 'testing' - ? 'index.html' - : config.cdn.index, - template: 'index.cdn.html', - inject: true, - minify: { - removeComments: true, - collapseWhitespace: false, - removeAttributeQuotes: true - }, - // necessary to consistently work with multiple chunks via CommonsChunkPlugin - chunksSortMode: 'dependency' - }) - ] -}) - -if (config.cdn.bundleAnalyzerReport) { - const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin - webpackConfig.plugins.push(new BundleAnalyzerPlugin()) -} - -module.exports = webpackConfig diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 2f17259..a8e323c 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -26,8 +26,12 @@ const webpackConfig = merge(baseWebpackConfig, { 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') + filename: utils.assetsPath('vuecsv.min.js'), + library: 'VueCSV', + libraryTarget: 'umd' + }, + externals: { + 'vue': 'Vue' }, plugins: [ // http://vuejs.github.io/vue-loader/en/workflow/production.html @@ -45,11 +49,7 @@ const webpackConfig = merge(baseWebpackConfig, { }), // 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`, - // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 + filename: utils.assetsPath('vuecsv.min.css'), allChunks: true, }), // Compress extracted CSS. We are using this plugin so that possible @@ -70,77 +70,15 @@ const webpackConfig = merge(baseWebpackConfig, { inject: true, minify: { removeComments: true, - collapseWhitespace: true, + collapseWhitespace: false, removeAttributeQuotes: true - // more options: - // https://github.com/kangax/html-minifier#options-quick-reference }, // necessary to consistently work with multiple chunks via CommonsChunkPlugin chunksSortMode: 'dependency' - }), - // keep module.id stable when vendor 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 (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 - ) - } - }), - // 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 - }), - // 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) { - const CompressionWebpackPlugin = require('compression-webpack-plugin') - - webpackConfig.plugins.push( - new CompressionWebpackPlugin({ - asset: '[path].gz[query]', - algorithm: 'gzip', - test: new RegExp( - '\\.(' + - config.build.productionGzipExtensions.join('|') + - ')$' - ), - threshold: 10240, - minRatio: 0.8 - }) - ) -} - if (config.build.bundleAnalyzerReport) { const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin webpackConfig.plugins.push(new BundleAnalyzerPlugin()) diff --git a/config/cdn.env.js b/config/cdn.env.js deleted file mode 100644 index 3e80cb2..0000000 --- a/config/cdn.env.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' -module.exports = { - NODE_ENV: '"cdn"' -} diff --git a/config/index.js b/config/index.js index 60a1b96..04b1cd8 100644 --- a/config/index.js +++ b/config/index.js @@ -49,38 +49,7 @@ module.exports = { // 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 - }, - - cdn: { - // Template for index.html - index: path.resolve(__dirname, '../dist/index.cdn.html'), - - // Paths - assetsRoot: path.resolve(__dirname, '../dist'), - assetsSubDirectory: 'static', + assetsSubDirectory: '', assetsPublicPath: '/', /** diff --git a/index.cdn.html b/index.cdn.html deleted file mode 100644 index 35334fd..0000000 --- a/index.cdn.html +++ /dev/null @@ -1,24 +0,0 @@ - - -
- - -