-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
184 additions
and
12 deletions.
There are no files selected for viewing
Empty file.
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,37 @@ | ||
'use strict' | ||
require('./check-versions')() | ||
|
||
process.env.NODE_ENV = 'plugin' | ||
|
||
const ora = require('ora') | ||
const rm = require('rimraf') | ||
const path = require('path') | ||
const chalk = require('chalk') | ||
const webpack = require('webpack') | ||
const config = require('../config') | ||
const webpackConfig = require('./webpack.plugin.conf') | ||
|
||
const spinner = ora('building for plugin...') | ||
spinner.start() | ||
|
||
rm(path.join(config.plugin.assetsRoot, config.plugin.assetsSubDirectory), err => { | ||
if (err) throw err | ||
webpack(webpackConfig, (err, stats) => { | ||
spinner.stop() | ||
if (err) throw err | ||
process.stdout.write(stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. | ||
chunks: false, | ||
chunkModules: false | ||
}) + '\n\n') | ||
|
||
if (stats.hasErrors()) { | ||
console.log(chalk.red(' Build failed with errors.\n')) | ||
process.exit(1) | ||
} | ||
|
||
console.log(chalk.cyan(' Build complete.\n')) | ||
}) | ||
}) |
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
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,96 @@ | ||
'use strict' | ||
const path = require('path') | ||
const utils = require('./utils') | ||
const webpack = require('webpack') | ||
const config = require('../config') | ||
const merge = require('webpack-merge') | ||
const baseWebpackConfig = require('./webpack.base.conf') | ||
const CopyWebpackPlugin = require('copy-webpack-plugin') | ||
const ExtractTextPlugin = require('extract-text-webpack-plugin') | ||
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') | ||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin') | ||
|
||
const env = 'plugin' | ||
|
||
const webpackConfig = merge(baseWebpackConfig, { | ||
module: { | ||
rules: utils.styleLoaders({ | ||
sourceMap: false, | ||
extract: true, | ||
usePostCSS: true | ||
}) | ||
}, | ||
devtool: false, | ||
entry: './assets/js/vendor/dialog.js', | ||
output: { | ||
path: path.resolve(__dirname, '../plugin/dist/static'), | ||
filename: 'js/vue.dialog.js', | ||
libraryTarget: 'umd' | ||
}, | ||
plugins: [ | ||
// http://vuejs.github.io/vue-loader/en/workflow/production.html | ||
new webpack.DefinePlugin({ | ||
'process.env': env | ||
}), | ||
new UglifyJsPlugin({ | ||
uglifyOptions: { | ||
compress: { | ||
warnings: false | ||
} | ||
}, | ||
sourceMap: config.plugin.productionSourceMap, | ||
parallel: true | ||
}), | ||
// extract css into its own file | ||
new ExtractTextPlugin({ | ||
filename: utils.assetsPath('css/dialog.min.css'), | ||
// Setting the following option to `false` will not extract CSS from codesplit chunks. | ||
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. | ||
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, | ||
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 | ||
allChunks: true, | ||
}), | ||
// Compress extracted CSS. We are using this plugin so that possible | ||
// duplicated CSS from different components can be deduped. | ||
new OptimizeCSSPlugin({ | ||
cssProcessorOptions: config.plugin.productionSourceMap | ||
? { safe: true, map: { inline: false } } | ||
: { safe: true } | ||
}), | ||
// enable scope hoisting | ||
new webpack.optimize.ModuleConcatenationPlugin(), | ||
// copy custom static assets | ||
new CopyWebpackPlugin([ | ||
{ | ||
from: path.resolve(__dirname, '../static'), | ||
to: config.plugin.assetsSubDirectory, | ||
ignore: ['.*'] | ||
} | ||
]) | ||
] | ||
}) | ||
|
||
if (config.plugin.productionGzip) { | ||
const 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 | ||
}) | ||
) | ||
} | ||
|
||
if (config.plugin.bundleAnalyzerReport) { | ||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | ||
webpackConfig.plugins.push(new BundleAnalyzerPlugin()) | ||
} | ||
|
||
module.exports = webpackConfig |
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,4 @@ | ||
'use strict' | ||
module.exports = { | ||
NODE_ENV: '"plugin"' | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.