10 examples of 'webpack provide plugin' in JavaScript

Every line of 'webpack provide plugin' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
48function plugins(debug) {
49 var pluginsList = [];
50
51 if (!debug) {
52 pluginsList.push(new webpack.DefinePlugin({
53 'process.env': {
54 'NODE_ENV': JSON.stringify('production')
55 }
56 }));
57
58 pluginsList.push(new webpack.optimize.DedupePlugin());
59
60 pluginsList.push(new ExtractTextPlugin('style.css', {
61 allChunks: true
62 }));
63
64 pluginsList.push(new webpack.optimize.UglifyJsPlugin());
65 } else {
66 pluginsList.push(new webpack.HotModuleReplacementPlugin());
67 pluginsList.push(new webpack.NoErrorsPlugin());
68 }
69
70 return pluginsList;
71}
212function getNoErrorsPlugin(webpack) {
213 // Important: Without this webpack tries to apply hot updates for broken
214 // builds and results in duplicate React nodes attached
215 // See https://github.com/webpack/webpack/issues/2117
216 // Note: NoEmitOnErrorsPlugin replaced NoErrorsPlugin since webpack 2.x
217 return webpack.NoEmitOnErrorsPlugin
218 ? new webpack.NoEmitOnErrorsPlugin()
219 : new webpack.NoErrorsPlugin();
220}
18function getPlugins() {
19 return [
20 // https://github.com/th0r/webpack-bundle-analyzer
21 // new BundleAnalyzerPlugin({
22 // openAnalyzer: false,
23 // }),
24
25 // https://github.com/lodash/lodash-webpack-plugin
26 new LodashModuleReplacementPlugin(),
27
28 // https://github.com/jantimon/html-webpack-plugin
29 new HtmlWebpackPlugin({
30 alwaysWriteToDisk: true,
31 filename: 'index.hbs',
32 inject: 'body',
33 template: path.join(appPath, 'views', 'index.hbs'),
34 }),
35
36 // https://github.com/jantimon/html-webpack-harddisk-plugin
37 // used because of webpack dev middleware
38 new HtmlWebpackHarddiskPlugin({
39 // set the output to the build directory
40 outputPath: path.join(buildPath, 'views'),
41 }),
42
43 // https://webpack.js.org/plugins/define-plugin
44 new webpack.DefinePlugin({
45 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
46 }),
47
48 // https://webpack.js.org/plugins/commons-chunk-plugin
49 new webpack.optimize.CommonsChunkPlugin({
50 name: 'vendor',
51 // https://webpack.js.org/guides/code-splitting-libraries/#implicit-common-vendor-chunk
52 minChunks: module => module.context && module.context.indexOf('node_modules') !== -1,
53 }),
54
55 // https://webpack.js.org/plugins/commons-chunk-plugin
56 new webpack.optimize.CommonsChunkPlugin({
57 // https://webpack.js.org/plugins/commons-chunk-plugin/#manifest-file
58 name: 'manifest',
59 minChunks: Infinity,
60 }),
61
62 // https://github.com/glenjamin/webpack-hot-middleware
63 new webpack.HotModuleReplacementPlugin(),
64 ];
65}
19var getDefinePlugin = function getDefinePlugin(name) {
20 return new _webpack.DefinePlugin({ __HOT__: process.env.NODE_ENV === 'hot',
21 __BASEURL__: _config.baseUrl,
22 'process.env.NODE_ENV': '"' + (NODE_ENV || 'development') + '"'
23 });
24};
64function getPlugins(isProduction) {
65 return [
66 new HtmlWebpackPlugin({
67 filename: path.join(config.buildDir, "index.html"),
68 template: config.indexHtmlTemplate,
69 // minify: isProduction ? {} : false
70 }),
71 new HtmlWebpackPolyfillIOPlugin({ features: "es6,fetch" }),
72 // new DynamicCdnWebpackPlugin({ verbose: true, only: config.cdnModules }),
73 ];
74}
25function WebpackPluginDone() {
26
27 let launched = false;
28 this.plugin('done', (stats) => {
29 if (!launched) {
30 launched = true;
31 browser(argv, skyPagesConfig, stats, this.options.devServer.port);
32 }
33 });
34}
1480configureUglifyJsPlugin() {
1481 throw new Error('The configureUglifyJsPlugin() method was removed from Encore due to uglify-js dropping ES6+ support in its latest version. Please use configureTerserPlugin() instead.');
1482}
68function getVueLoaderPlugin() {
69 return new VueLoaderPlugin();
70}
265function extendPlugins(plugins) {
266 if (!isProduction) {
267 plugins.unshift(new webpack.HotModuleReplacementPlugin());
268 } else {
269 plugins.push(
270 extractCSS,
271 new SvgSpriteLoaderPlugin(),
272 new OptimizeCssAssetsPlugin({
273 cssProcessorOptions: { discardComments: { removeAll: true } },
274 canPrint: false,
275 }),
276 new webpack.optimize.UglifyJsPlugin({
277 compress: { warnings: false },
278 sourceMap: true,
279 })
280 );
281 }
282 return plugins;
283}
4export default function plugin (opts={}) {
5 let cfg = {
6 // defaults
7 include: [ '**/*.scss' ],
8 exclude: [ 'node_modules/**' ],
9 options: {},
10
11 // outside options (overrides)
12 ...opts
13 };
14
15 const filter = createFilter(cfg.include, cfg.exclude);
16
17 return {
18 name: 'scss',
19 transform: function transform (fileData, fileName) {
20 if (!filter(fileName)) {
21 return null;
22 }
23
24 try {
25 let rendered = sass.renderSync({
26 ...cfg.options,
27 data: fileData,
28 file: fileName,
29 });
30
31 return `export default ${JSON.stringify(rendered.css.toString())};`;
32 } catch (err) {
33 throw new Error(err.formatted);
34 }
35 }
36 };
37};

Related snippets