mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
✨ Add umd module gereation for npm package
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
This commit is contained in:
@@ -14,13 +14,13 @@ console.log(
|
|||||||
' Opening index.html over file:// won\'t work.\n'
|
' Opening index.html over file:// won\'t work.\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
var spinner = ora('building for production...')
|
var spinner = ora('building UMD module...')
|
||||||
spinner.start()
|
spinner.start()
|
||||||
|
|
||||||
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
|
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
|
||||||
rm('-rf', assetsPath)
|
rm('-rf', assetsPath)
|
||||||
mkdir('-p', assetsPath)
|
mkdir('-p', assetsPath)
|
||||||
cp('-R', 'static/', assetsPath)
|
|
||||||
|
|
||||||
webpack(webpackConfig, function (err, stats) {
|
webpack(webpackConfig, function (err, stats) {
|
||||||
spinner.stop()
|
spinner.stop()
|
||||||
|
|||||||
@@ -1,102 +1,32 @@
|
|||||||
var path = require('path')
|
const webpack = require('webpack')
|
||||||
var config = require('../config')
|
const base = require('./webpack.base.conf')
|
||||||
var utils = require('./utils')
|
const config = require('../config')
|
||||||
var webpack = require('webpack')
|
|
||||||
var merge = require('webpack-merge')
|
|
||||||
var baseWebpackConfig = require('./webpack.base.conf')
|
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
||||||
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
||||||
var env = process.env.NODE_ENV === 'testing'
|
|
||||||
? require('../config/test.env')
|
|
||||||
: config.build.env
|
|
||||||
|
|
||||||
var webpackConfig = merge(baseWebpackConfig, {
|
base.entry = {
|
||||||
module: {
|
lib: './src/index.js'
|
||||||
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true })
|
}
|
||||||
},
|
|
||||||
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
base.output = {
|
||||||
output: {
|
|
||||||
path: config.build.assetsRoot,
|
path: config.build.assetsRoot,
|
||||||
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
publicPath: config.build.assetsPublicPath,
|
||||||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
filename: 'vue-chartjs.js',
|
||||||
},
|
library: 'VueChartJs',
|
||||||
vue: {
|
libraryTarget: 'umd'
|
||||||
loaders: utils.cssLoaders({
|
}
|
||||||
sourceMap: config.build.productionSourceMap,
|
|
||||||
extract: true
|
var webpackConfig = Object.assign({}, base)
|
||||||
})
|
|
||||||
},
|
webpackConfig.devtool = '#source-map'
|
||||||
plugins: [
|
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
|
||||||
// http://vuejs.github.io/vue-loader/workflow/production.html
|
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': env
|
'process.env': {
|
||||||
|
NODE_ENV: '"production"'
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
compress: {
|
compress: { warnings: false }
|
||||||
warnings: false
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
new webpack.optimize.OccurenceOrderPlugin(),
|
||||||
// extract css into its own file
|
])
|
||||||
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
|
|
||||||
// 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.build.index,
|
|
||||||
template: 'index.html',
|
|
||||||
inject: true,
|
|
||||||
minify: {
|
|
||||||
removeComments: true,
|
|
||||||
collapseWhitespace: 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'
|
|
||||||
}),
|
|
||||||
// split vendor js into its own file
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: 'vendor',
|
|
||||||
minChunks: function (module, count) {
|
|
||||||
// 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',
|
|
||||||
chunks: ['vendor']
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
if (config.build.productionGzip) {
|
|
||||||
var 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
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = webpackConfig
|
module.exports = webpackConfig
|
||||||
|
|||||||
@@ -4,21 +4,18 @@ var path = require('path')
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
build: {
|
build: {
|
||||||
env: require('./prod.env'),
|
env: require('./prod.env'),
|
||||||
index: path.resolve(__dirname, '../dist/index.html'),
|
|
||||||
assetsRoot: path.resolve(__dirname, '../dist'),
|
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||||
assetsSubDirectory: 'static',
|
assetsSubDirectory: '',
|
||||||
assetsPublicPath: '/',
|
assetsPublicPath: '/',
|
||||||
productionSourceMap: true,
|
productionSourceMap: true,
|
||||||
// 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']
|
|
||||||
},
|
},
|
||||||
dev: {
|
dev: {
|
||||||
env: require('./dev.env'),
|
env: require('./dev.env'),
|
||||||
port: 8080,
|
port: 8080,
|
||||||
proxyTable: {}
|
proxyTable: {}
|
||||||
|
},
|
||||||
|
umd: {
|
||||||
|
assetsRoot: path.resolve(__dirname, '../umd'),
|
||||||
|
assetsPublicPath: '/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
dist/vue-chartjs.js
vendored
Normal file
20
dist/vue-chartjs.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/vue-chartjs.js.map
vendored
Normal file
1
dist/vue-chartjs.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-chartjs",
|
"name": "vue-chartjs",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "Vue wrapper for chart.js",
|
"description": "Vue wrapper for chart.js",
|
||||||
"author": "Jakub Juszczak <jakub@nextindex.de>",
|
"author": "Jakub Juszczak <jakub@nextindex.de>",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
"ChartJs",
|
"ChartJs",
|
||||||
"Vue",
|
"Vue",
|
||||||
"Visualisation",
|
"Visualisation",
|
||||||
"Wrapper"
|
"Wrapper",
|
||||||
|
"Charts"
|
||||||
],
|
],
|
||||||
"private": true,
|
"main": "dist/vue-chartjs.js",
|
||||||
"main": "src/index.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node build/dev-server.js",
|
"dev": "node build/dev-server.js",
|
||||||
"build": "node build/build.js",
|
"build": "node build/build.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user