Skip to content

Commit b4db310

Browse files
authored
Merge pull request #6 from ynishi/refactor_dir
refactor build setting and dir
2 parents 3749c75 + f3bf6e2 commit b4db310

File tree

13 files changed

+32
-274
lines changed

13 files changed

+32
-274
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ npm run buildcdn && open dist/index.cdn.html
1010
```
1111
* CDN
1212
```
13-
<link rel="stylesheet" href="https://unpkg.com/vuecsv/dist/static/css/app.cdn.css">
14-
<script type="text/javascript" src="https://unpkg.com/vuecsv/dist/static/js/app.cdn.js"></script>
13+
<link rel="stylesheet" href="https://unpkg.com/vuecsv/dist/vuecsv.min.css">
14+
<script type="text/javascript" src="https://unpkg.com/vuecsv/dist/vuecsv.min.js"></script>
1515
```
1616

1717
## Build Setup
@@ -29,9 +29,6 @@ npm run build
2929
# build for production and view the bundle analyzer report
3030
npm run build --report
3131

32-
# build for production support browser
33-
npm run buildcdn
34-
3532
# run unit tests
3633
npm run unit
3734

build/build.cdn.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

build/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const webpack = require('webpack')
1111
const config = require('../config')
1212
const webpackConfig = require('./webpack.prod.conf')
1313

14-
const spinner = ora('building for production...')
14+
const spinner = ora('building ...')
1515
spinner.start()
1616

1717
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {

build/logo.png

-6.69 KB
Binary file not shown.

build/utils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin')
55
const packageConfig = require('../package.json')
66

77
exports.assetsPath = function (_path) {
8-
const assetsSubDirectory = (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'cdn')
8+
const assetsSubDirectory = process.env.NODE_ENV === 'production'
99
? config.build.assetsSubDirectory
1010
: config.dev.assetsSubDirectory
1111

@@ -94,8 +94,7 @@ exports.createNotifierCallback = () => {
9494
notifier.notify({
9595
title: packageConfig.name,
9696
message: severity + ': ' + error.name,
97-
subtitle: filename || '',
98-
icon: path.join(__dirname, 'logo.png')
97+
subtitle: filename || ''
9998
})
10099
}
101100
}

build/webpack.cdn.conf.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

build/webpack.prod.conf.js

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ const webpackConfig = merge(baseWebpackConfig, {
2626
devtool: config.build.productionSourceMap ? config.build.devtool : false,
2727
output: {
2828
path: config.build.assetsRoot,
29-
filename: utils.assetsPath('js/[name].[chunkhash].js'),
30-
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
29+
filename: utils.assetsPath('vuecsv.min.js'),
30+
library: 'VueCSV',
31+
libraryTarget: 'umd'
32+
},
33+
externals: {
34+
'vue': 'Vue'
3135
},
3236
plugins: [
3337
// http://vuejs.github.io/vue-loader/en/workflow/production.html
@@ -45,11 +49,7 @@ const webpackConfig = merge(baseWebpackConfig, {
4549
}),
4650
// extract css into its own file
4751
new ExtractTextPlugin({
48-
filename: utils.assetsPath('css/[name].[contenthash].css'),
49-
// Setting the following option to `false` will not extract CSS from codesplit chunks.
50-
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
51-
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
52-
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
52+
filename: utils.assetsPath('vuecsv.min.css'),
5353
allChunks: true,
5454
}),
5555
// Compress extracted CSS. We are using this plugin so that possible
@@ -70,77 +70,15 @@ const webpackConfig = merge(baseWebpackConfig, {
7070
inject: true,
7171
minify: {
7272
removeComments: true,
73-
collapseWhitespace: true,
73+
collapseWhitespace: false,
7474
removeAttributeQuotes: true
75-
// more options:
76-
// https://github.com/kangax/html-minifier#options-quick-reference
7775
},
7876
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
7977
chunksSortMode: 'dependency'
80-
}),
81-
// keep module.id stable when vendor modules does not change
82-
new webpack.HashedModuleIdsPlugin(),
83-
// enable scope hoisting
84-
new webpack.optimize.ModuleConcatenationPlugin(),
85-
// split vendor js into its own file
86-
new webpack.optimize.CommonsChunkPlugin({
87-
name: 'vendor',
88-
minChunks (module) {
89-
// any required modules inside node_modules are extracted to vendor
90-
return (
91-
module.resource &&
92-
/\.js$/.test(module.resource) &&
93-
module.resource.indexOf(
94-
path.join(__dirname, '../node_modules')
95-
) === 0
96-
)
97-
}
98-
}),
99-
// extract webpack runtime and module manifest to its own file in order to
100-
// prevent vendor hash from being updated whenever app bundle is updated
101-
new webpack.optimize.CommonsChunkPlugin({
102-
name: 'manifest',
103-
minChunks: Infinity
104-
}),
105-
// This instance extracts shared chunks from code splitted chunks and bundles them
106-
// in a separate chunk, similar to the vendor chunk
107-
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
108-
new webpack.optimize.CommonsChunkPlugin({
109-
name: 'app',
110-
async: 'vendor-async',
111-
children: true,
112-
minChunks: 3
113-
}),
114-
115-
// copy custom static assets
116-
new CopyWebpackPlugin([
117-
{
118-
from: path.resolve(__dirname, '../static'),
119-
to: config.build.assetsSubDirectory,
120-
ignore: ['.*']
121-
}
122-
])
78+
})
12379
]
12480
})
12581

126-
if (config.build.productionGzip) {
127-
const CompressionWebpackPlugin = require('compression-webpack-plugin')
128-
129-
webpackConfig.plugins.push(
130-
new CompressionWebpackPlugin({
131-
asset: '[path].gz[query]',
132-
algorithm: 'gzip',
133-
test: new RegExp(
134-
'\\.(' +
135-
config.build.productionGzipExtensions.join('|') +
136-
')$'
137-
),
138-
threshold: 10240,
139-
minRatio: 0.8
140-
})
141-
)
142-
}
143-
14482
if (config.build.bundleAnalyzerReport) {
14583
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
14684
webpackConfig.plugins.push(new BundleAnalyzerPlugin())

config/cdn.env.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

config/index.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,7 @@ module.exports = {
4949

5050
// Paths
5151
assetsRoot: path.resolve(__dirname, '../dist'),
52-
assetsSubDirectory: 'static',
53-
assetsPublicPath: '/',
54-
55-
/**
56-
* Source Maps
57-
*/
58-
59-
productionSourceMap: true,
60-
// https://webpack.js.org/configuration/devtool/#production
61-
devtool: '#source-map',
62-
63-
// Gzip off by default as many popular static hosts such as
64-
// Surge or Netlify already gzip all static assets for you.
65-
// Before setting to `true`, make sure to:
66-
// npm install --save-dev compression-webpack-plugin
67-
productionGzip: false,
68-
productionGzipExtensions: ['js', 'css'],
69-
70-
// Run the build command with an extra argument to
71-
// View the bundle analyzer report after build finishes:
72-
// `npm run build --report`
73-
// Set to `true` or `false` to always turn it on or off
74-
bundleAnalyzerReport: process.env.npm_config_report
75-
},
76-
77-
cdn: {
78-
// Template for index.html
79-
index: path.resolve(__dirname, '../dist/index.cdn.html'),
80-
81-
// Paths
82-
assetsRoot: path.resolve(__dirname, '../dist'),
83-
assetsSubDirectory: 'static',
52+
assetsSubDirectory: '',
8453
assetsPublicPath: '/',
8554

8655
/**

index.cdn.html

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)