-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(webpack): use CDNs and dll plugin
- Loading branch information
1 parent
3c58e1b
commit 37fbc61
Showing
9 changed files
with
180 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ coverage/ | |
dist/ | ||
docs/build | ||
docs/app/docgenInfo.json | ||
dll/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import webpack from 'webpack' | ||
|
||
import config from '../config' | ||
const webpackDllConfig = { module: {} } | ||
|
||
const { paths } = config | ||
|
||
// ------------------------------------ | ||
// Entry Points | ||
// ------------------------------------ | ||
webpackDllConfig.entry = { | ||
vendor: config.compiler_vendor, | ||
} | ||
|
||
// ------------------------------------ | ||
// Bundle Output | ||
// ------------------------------------ | ||
webpackDllConfig.output = { | ||
...webpackDllConfig.output, | ||
path: 'dll', | ||
filename: `dll.[name].[${config.compiler_hash_type}].js`, | ||
library: '[name]_[hash]', | ||
} | ||
|
||
// ------------------------------------ | ||
// Plugins | ||
// ------------------------------------ | ||
webpackDllConfig.plugins = [ | ||
new webpack.DllPlugin({ | ||
path: paths.base('dll', '[name]-manifest.json'), | ||
name: '[name]_[hash]', | ||
}), | ||
] | ||
|
||
// ------------------------------------ | ||
// Pre-Loaders | ||
// ------------------------------------ | ||
webpackDllConfig.module.preLoaders = [] | ||
|
||
// ------------------------------------ | ||
// Loaders | ||
// ------------------------------------ | ||
webpackDllConfig.module.loaders = [{ | ||
// | ||
// JSON | ||
// | ||
test: /\.json$/, | ||
loader: 'json', | ||
}, { | ||
// | ||
// SASS | ||
// | ||
test: /\.s?css$/, | ||
loaders: ['style', 'css', 'sass'], | ||
}, { | ||
// | ||
// Files | ||
// | ||
test: /\.(eot|ttf|woff|woff2|svg|png)$/, | ||
loader: 'file', | ||
}] | ||
|
||
export default webpackDllConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { task } from 'gulp' | ||
import loadPlugins from 'gulp-load-plugins' | ||
import webpack from 'webpack' | ||
|
||
import config from '../../config' | ||
|
||
const g = loadPlugins() | ||
const { log, PluginError } = g.util | ||
|
||
task('dll', (cb) => { | ||
const webpackDLLConfig = require('../../build/webpack.dll').default | ||
const compiler = webpack(webpackDLLConfig) | ||
|
||
compiler.run((err, stats) => { | ||
const { errors, warnings } = stats.toJson() | ||
|
||
log(stats.toString(config.compiler_stats)) | ||
|
||
if (err) { | ||
log('Webpack compiler encountered a fatal error.') | ||
throw new PluginError('webpack', err.toString()) | ||
} | ||
if (errors.length > 0) { | ||
log('Webpack compiler encountered errors.') | ||
throw new PluginError('webpack', errors.toString()) | ||
} | ||
if (warnings.length > 0 && config.compiler_fail_on_warning) { | ||
throw new PluginError('webpack', warnings.toString()) | ||
} | ||
|
||
cb(err) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters