Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const webpack = require('webpack')
const path = require('path')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const BabelPlugin = require('webpack-babel-plugin')
module.exports = {
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'webpack-bundle.js'
},
module: {
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: true,
// pure_getters: true
// },
// mangle: false,
// output: {
// beautify: true,
// indent_level: 2
// }
// }),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: true,
pure_getters: true
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.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(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
var rename = require('gulp-rename');
var minimist = require('minimist');
var gutil = require("gulp-util");
var rev = require('gulp-rev-hash');
var path = require('path');
var pwd = __dirname;
// gulp --env=pro 压缩代码,直接执行gulp,不压缩代码
var argv = require('minimist')(process.argv.slice(2));
// var config = require('./config.json');
var rootPath = __dirname;
var vendorPlugin = new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.min.js',
minChunks: Infinity,
});
var webpackConfig = {
entry: {
DataPlatform: './src/js/app.js',
vendor: [
pwd + '/src/js/lib/vue.min.js',
pwd + '/src/js/lib/vuex.min.js',
pwd + '/src/js/lib/jquery.min.js',
pwd + '/src/js/lib/bootstrap.min.js',
pwd + '/src/js/lib/metisMenu.min.js',
pwd + '/src/js/lib/moment.min.js',
pwd + '/src/js/lib/datePicker.min.js',
pwd + '/src/js/lib/jquery-table.min.js',
test('pluginSupport', t => {
const filename = '[name].[hash].js';
const entry = {
vendor: ['react', 'react-dom']
};
const plugins = [
new webpack.optimize.UglifyJsPlugin({
compress: true
})
];
const originalSettings = { filename, entry, plugins };
const hash = createHash(originalSettings);
const settings = Object.assign({}, originalSettings, { hash: hash });
const outputPath = path.join(cacheDir, hash);
const results = createConfig(settings);
const expected = {
resolve: {
extensions: ['.js', '.jsx']
},
entry: entry,
'use strict';
var webpack = require('webpack');
var baseConfig = require('./config.base');
var config = Object.create(baseConfig);
config.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
];
module.exports = config;
var webpack = require('webpack');
var externals = require('frint-config').externals;
var minify = process.env.DIST_MIN;
var plugins = !minify
? []
: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false
}
})
];
var filename = !minify
? 'frint-router.js'
: 'frint-router.min.js';
module.exports = {
entry: __dirname + '/src',
output: {
path: __dirname + '/dist',
filename: filename,
libraryTarget: 'umd',
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: ['./src/Main.js'],
output: {
path: path.resolve(__dirname, './dist'),
filename: 'build.js',
library: ['VueNativeSock'],
libraryTarget: 'umd'
},
devtool: "source-map",
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
}
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
resolve: {
extensions: ['', '.ts', '.js']
},
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['ts-loader']
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['application', 'vendor', 'polyfills']
})/*,
new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: {screw_ie8: true, keep_fnames: true},
compress: {screw_ie8: true},
comments: false
})*/
]
};
);
}
if (Mix.copy) {
Mix.copy.forEach(copy => {
module.exports.plugins.push(
new plugins.CopyWebpackPlugin([copy])
);
});
}
if (Mix.js.vendor) {
module.exports.plugins.push(
new webpack.optimize.CommonsChunkPlugin({
names: [Mix.js.base + '/vendor', Mix.js.base + '/' + 'manifest'],
minChunks: Infinity
})
);
}
if (Mix.inProduction) {
module.exports.plugins = module.exports.plugins.concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
filename: 'vendors/vendors.dashboard.[chunkhash].js',
library: 'vendors_dashboard_worona',
hashDigestLength: 32,
},
resolve: {
root: path.resolve('../../node_modules'),
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, '..', 'dist', 'prod', 'vendors', 'vendors-manifest.json'),
name: 'vendors_dashboard_worona',
context: path.join(__dirname, '..', '..', '..'),
}),
new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') } }),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new FixModuleIdAndChunkIdPlugin(),
new StatsWriterPlugin({
filename: '../../package.json',
fields: ['chunks'],
transform: function (data) {
worona.prod = worona.prod || {};
worona.prod.vendors = { files: [] };
data.chunks.forEach(chunk => chunk.files.forEach((file, index) => {
const chunkName = chunk.names[index];
if (chunkName === 'vendors') {
worona.prod.vendors.main = packageJson.name + '/dist/prod/' + file;
}
worona.prod.vendors.files.push({
file: packageJson.name + '/dist/prod/' + file,
hash: chunk.hash,