Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: remove DLL option
BREAKING CHANGE: dll option has been removed.
  • Loading branch information
yyx990803 committed May 7, 2018
1 parent ab0746e commit 6d4e51d
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 216 deletions.
28 changes: 0 additions & 28 deletions docs/cli-service.md
Expand Up @@ -6,7 +6,6 @@
- [build](#build)
- [Caching and Parallel Mode](#caching-and-parallel-mode)
- [Building as Library or Web Component](#building-as-library-or-web-component)
- [DLL Mode](#dll-mode)
- [inspect](#inspect)
- [Checking All Available Commands](#checking-all-available-commands)

Expand Down Expand Up @@ -118,33 +117,6 @@ Options:

It is also possible to build any component(s) inside your project as a library or as web components. See [Build Targets](./build-targets.md) for more details.

#### DLL Mode

If your app has a large amount of dependency libraries, you can improve the build performance by opting into DLL mode. DLL mode builds your dependencies into a separate vendor bundle which will be reused on future builds as long as your dependencies did not change.

To enable DLL mode, set the `dll` option in `vue.config.js` to `true`:

``` js
// vue.config.js
module.exports = {
dll: true
}
```

This by default builds **all the modules listed in the `dependencies` field in `package.json`** into the DLL bundle. It is important that you correctly list your dependencies, otherwise it may end up including unnecessary code.

If you wish to have finer grained control over what modules to be included in the DLL bundle, you can also provide an Array of modules to the `dll` option:

``` js
// vue.config.js
module.exports = {
dll: [
'dep-a',
'dep-b/some/nested/file.js'
]
}
```

### inspect

```
Expand Down
11 changes: 3 additions & 8 deletions docs/config.md
Expand Up @@ -34,14 +34,14 @@ module.exports = {
// performance.
preserveWhitepsace: false,

// generate sourceMap for production build?
productionSourceMap: true,

// tweak internal webpack configuration.
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
chainWebpack: () => {},
configureWebpack: () => {},

// generate sourceMap for production build?
productionSourceMap: true,

// CSS related options
css: {
// extract CSS in components into a single CSS file (only in production)
Expand All @@ -64,11 +64,6 @@ module.exports = {
// enabled by default if the machine has more than 1 cores
parallel: require('os').cpus().length > 1,

// split vendors using autoDLLPlugin?
// can also be an explicit Array of dependencies to include in the DLL chunk.
// See https://github.com/vuejs/vue-cli/blob/dev/docs/cli-service.md#dll-mode
dll: false,

// options for the PWA plugin.
// see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
pwa: {},
Expand Down
62 changes: 0 additions & 62 deletions packages/@vue/cli-service/__tests__/buildDLL.spec.js

This file was deleted.

105 changes: 36 additions & 69 deletions packages/@vue/cli-service/lib/config/app.js
Expand Up @@ -67,47 +67,45 @@ module.exports = (api, options) => {
// This needs to be updated when upgrading to webpack 4
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')

if (!options.dll) {
// extract vendor libs into its own chunk for better caching, since they
// are more likely to stay the same.
webpackConfig
.plugin('split-vendor')
.use(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(`node_modules`) > -1
)
}
}])
// extract vendor libs into its own chunk for better caching, since they
// are more likely to stay the same.
webpackConfig
.plugin('split-vendor')
.use(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(`node_modules`) > -1
)
}
}])

// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
webpackConfig
.plugin('split-manifest')
.use(CommonsChunkPlugin, [{
name: 'manifest',
minChunks: Infinity
}])
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
webpackConfig
.plugin('split-manifest')
.use(CommonsChunkPlugin, [{
name: 'manifest',
minChunks: Infinity
}])

// inline the manifest chunk into HTML
webpackConfig
.plugin('inline-manifest')
.use(require('../webpack/InlineSourcePlugin'), [{
include: /manifest\..*\.js$/
}])
// inline the manifest chunk into HTML
webpackConfig
.plugin('inline-manifest')
.use(require('../webpack/InlineSourcePlugin'), [{
include: /manifest\..*\.js$/
}])

// since manifest is inlined, don't preload it anymore
webpackConfig
.plugin('preload')
.tap(([options]) => {
options.fileBlacklist.push(/manifest\..*\.js$/)
return [options]
})
}
// since manifest is inlined, don't preload it anymore
webpackConfig
.plugin('preload')
.tap(([options]) => {
options.fileBlacklist.push(/manifest\..*\.js$/)
return [options]
})

// This CommonsChunkPlugin instance extracts shared chunks from async
// chunks and bundles them in a separate chunk, similar to the vendor chunk
Expand All @@ -120,37 +118,6 @@ module.exports = (api, options) => {
children: true,
minChunks: 3
}])

// DLL
if (options.dll) {
const webpack = require('webpack')
const UglifyPlugin = require('uglifyjs-webpack-plugin')
const getUglifyOptions = require('./uglifyOptions')
const dllEntries = Array.isArray(options.dll)
? options.dll
: Object.keys(api.service.pkg.dependencies)

webpackConfig
.plugin('dll')
.use(require('autodll-webpack-plugin'), [{
inject: true,
inherit: true,
path: 'js/',
context: api.resolve('.'),
filename: '[name].[hash:8].js',
entry: {
'vendor': [
...dllEntries,
'vue-loader/lib/component-normalizer'
]
},
plugins: [
new webpack.DefinePlugin(resolveClientEnv(options.baseUrl)),
new UglifyPlugin(getUglifyOptions(options))
]
}])
.after('preload')
}
}
})
}
8 changes: 0 additions & 8 deletions packages/@vue/cli-service/lib/options.js
Expand Up @@ -9,10 +9,6 @@ const schema = createSchema(joi => joi.object({
productionSourceMap: joi.boolean(),
parallel: joi.boolean(),
devServer: joi.object(),
dll: joi.alternatives().try(
joi.boolean(),
joi.array().items(joi.string())
),

// css
css: joi.object({
Expand Down Expand Up @@ -69,10 +65,6 @@ exports.defaults = () => ({
// enabled by default if the machine has more than 1 cores
parallel: require('os').cpus().length > 1,

// split vendors using autoDLLPlugin?
// can be an explicit list of dependencies to include in the DLL chunk.
dll: false,

css: {
// extract: true,
// modules: false,
Expand Down
1 change: 0 additions & 1 deletion packages/@vue/cli-service/package.json
Expand Up @@ -25,7 +25,6 @@
"@vue/cli-shared-utils": "^3.0.0-beta.9",
"@vue/web-component-wrapper": "^1.2.0",
"address": "^1.0.3",
"autodll-webpack-plugin": "^0.3.9",
"autoprefixer": "^8.3.0",
"cache-loader": "^1.2.2",
"case-sensitive-paths-webpack-plugin": "^2.1.2",
Expand Down

0 comments on commit 6d4e51d

Please sign in to comment.