From f3e1f46643b5eb448edefedcc47b0bd965ce27b7 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Thu, 2 Feb 2017 19:34:02 +0800 Subject: [PATCH 1/2] support custom filenames --- bin/vue-build | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/vue-build b/bin/vue-build index c89132b356..871d7d48bf 100755 --- a/bin/vue-build +++ b/bin/vue-build @@ -125,13 +125,15 @@ if (hasBabelRc) { babelOptions.presets.push(require.resolve('babel-preset-vue-app')) } +var filenames = getFilenames(options) + var webpackConfig = { entry: { client: [] }, output: { path: path.join(process.cwd(), options.dist), - filename: production ? '[name].[chunkhash:8].js' : '[name].js', + filename: filenames.js, publicPath: '/' }, performance: { @@ -175,7 +177,7 @@ var webpackConfig = { test: /\.(ico|jpg|png|gif|svg|eot|otf|webp|ttf|woff|woff2)(\?.*)?$/, loader: 'file-loader', query: { - name: options.lib ? 'static/[name].[ext]' : 'static/[name].[hash:8].[ext]' + name: filenames.assets } } ].concat(loaders.styleLoaders(cssOptions)) @@ -253,7 +255,7 @@ if (production) { new webpack.LoaderOptionsPlugin({ minimize: true }), - new ExtractTextPlugin(options.lib ? `${replaceExtension(options.entry, '.css')}` : '[name].[contenthash:8].css') + new ExtractTextPlugin(filenames.css) ) } else { if (!options.watch) { @@ -377,3 +379,11 @@ function handleBuild (err, stats, watch) { console.log(` ${chalk.yellow('serve')} ${options.dist} --single\n`) } } + +function getFilenames (options) { + return Object.assign({ + js: options.production ? '[name].[chunkhash:8].js' : '[name].js', + css: options.lib ? `${replaceExtension(options.entry, '.css')}` : '[name].[contenthash:8].css', + assets: options.lib ? 'static/[name].[ext]' : 'static/[name].[hash:8].[ext]' + }, options.filename) +} From 64fb1fcbd77d97d6fb8b2f690d750f9d817ea0f6 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Thu, 2 Feb 2017 19:43:09 +0800 Subject: [PATCH 2/2] update docs --- bin/vue-build | 4 ++-- docs/build.md | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/vue-build b/bin/vue-build index 871d7d48bf..16f0e9b4b1 100755 --- a/bin/vue-build +++ b/bin/vue-build @@ -177,7 +177,7 @@ var webpackConfig = { test: /\.(ico|jpg|png|gif|svg|eot|otf|webp|ttf|woff|woff2)(\?.*)?$/, loader: 'file-loader', query: { - name: filenames.assets + name: filenames.static } } ].concat(loaders.styleLoaders(cssOptions)) @@ -384,6 +384,6 @@ function getFilenames (options) { return Object.assign({ js: options.production ? '[name].[chunkhash:8].js' : '[name].js', css: options.lib ? `${replaceExtension(options.entry, '.css')}` : '[name].[contenthash:8].css', - assets: options.lib ? 'static/[name].[ext]' : 'static/[name].[hash:8].[ext]' + static: options.lib ? 'static/[name].[ext]' : 'static/[name].[hash:8].[ext]' }, options.filename) } diff --git a/docs/build.md b/docs/build.md index 65d757976c..685444f95f 100644 --- a/docs/build.md +++ b/docs/build.md @@ -38,7 +38,7 @@ If you want to directly test a component without manually create a Vue instance $ vue build Component.vue ``` -
How does this work? +
How does this work?
When the input file ends with `.vue` extension, we use a [default app entry](/lib/default-entry.es6) to load the given component, otherwise we treat it as a normal webpack entry. For jsx component which ends with `.js` extension, you can enable this behavior manually by adding `--mount`.
@@ -150,6 +150,20 @@ Type: `Object` Check out the [default template](/lib/template.html) file we use. +#### filename + +Set custom filename for `js` `css` `static` files: + +```js +{ + filename: { + js: 'index.js', + css: 'style.css', + static: 'static/[name].[ext]' + } +} +``` + #### proxy Type: `string`, `Object`