Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ npm run buildcdn && open dist/index.cdn.html
```
* CDN
```
<link rel="stylesheet" href="https://unpkg.com/vuecsv/dist/static/css/app.cdn.css">
<script type="text/javascript" src="https://unpkg.com/vuecsv/dist/static/js/app.cdn.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vuecsv/dist/vuecsv.min.css">
<script type="text/javascript" src="https://unpkg.com/vuecsv/dist/vuecsv.min.js"></script>
```

## Build Setup
Expand All @@ -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

Expand Down
41 changes: 0 additions & 41 deletions build/build.cdn.js

This file was deleted.

2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Binary file removed build/logo.png
Binary file not shown.
5 changes: 2 additions & 3 deletions build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 || ''
})
}
}
87 changes: 0 additions & 87 deletions build/webpack.cdn.conf.js

This file was deleted.

80 changes: 9 additions & 71 deletions build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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())
Expand Down
4 changes: 0 additions & 4 deletions config/cdn.env.js

This file was deleted.

33 changes: 1 addition & 32 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '/',

/**
Expand Down
24 changes: 0 additions & 24 deletions index.cdn.html

This file was deleted.

16 changes: 14 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>vuecsv</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<div id="app">
<csv-download :title="title" :data-json="d"></csv-download>
</div>
</body>
<script type=text/javascript>
Vue.component("csv-download", VueCSV.CsvDownload)
new Vue({
el:"#app",
data: {
title: 'download csv',
d: [{'a':1,'b':2},{'a':3,'b':4}]
}
})
</script>
</html>
Loading