<commit_before>const Path = require("path");
const Webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MergeIntoSingleFilePlugin = require("webpack-merge-and-include-globally");
const CopyPlugin = require("copy-webpack-plugin");

const context = Path.resolve(__dirname, ".");
const source = context + "/source";
const output = context + "/dist";

module.exports = {
	context: source,
	entry: source + "/editor/Main.js",
	target: "web",
	devtool: "inline-source-map",
	plugins: [
		new CopyPlugin({
			patterns: [
				{
					from: source + "/files",
					to: output + "/files",
					force: true
				}
			],
			options: {
				concurrency: 100,
			}
		}),
		new HtmlWebpackPlugin({template: source + "/editor/index.html", filename: "index.html"}),
		new Webpack.ProgressPlugin(),
		new Webpack.ProvidePlugin({
			THREE: "three",
			"window.THREE": "three"
		}),
		new MergeIntoSingleFilePlugin({
			files: {
				"styles.css": [
					"source/editor/style.css",
					"source/editor/theme/dark.css",
				],
				"jscolor.js": [
					"node_modules/@eastdesire/jscolor/jscolor.js",
				],
				/*"spine.js": [
					"node_modules/spine-runtimes/spine-ts/build/spine-threejs.js",
				],*/
				"jshint.js": [
					"node_modules/jshint/dist/jshint.js"
				],
				"acorn.js": [
					"node_modules/acorn/dist/acorn.js",
					"node_modules/acorn-loose/dist/acorn-loose.js",
					"node_modules/acorn-walk/dist/walk.js"
				],
				"tern.js": [
					"node_modules/tern/lib/signal.js",
					"node_modules/tern/lib/tern.js",
					"node_modules/tern/lib/def.js",
					"node_modules/tern/lib/comment.js",
					"node_modules/tern/lib/infer.js",
					"node_modules/tern/plugin/doc_comment.js"
				],
				"codemirror.js": [
					"node_modules/codemirror/lib/codemirror.js",
					"node_modules/codemirror/keymap/sublime.js",
					"node_modules/codemirror/keymap/emacs.js",
					"node_modules/codemirror/keymap/vim.js",
					"node_modules/codemirror/mode/javascript/javascript.js",
					"node_modules/codemirror/mode/css/css.js",
					"node_modules/codemirror/mode/xml/xml.js",
					"node_modules/codemirror/mode/htmlmixed/htmlmixed.js",
					"node_modules/codemirror/addon/edit/closebrackets.js",
					"node_modules/codemirror/addon/edit/matchbrackets.js",
					"node_modules/codemirror/addon/scroll/annotatescrollbar.js",
					"node_modules/codemirror/addon/search/search.js",
					"node_modules/codemirror/addon/search/searchcursor.js",
					"node_modules/codemirror/addon/search/jump-to-line.js",
					"node_modules/codemirror/addon/search/match-highlighter.js",
					"node_modules/codemirror/addon/search/matchesonscrollbar.js",
					"node_modules/codemirror/addon/hint/show-hint.js",
					"node_modules/codemirror/addon/hint/anyword-hint.js",
					"node_modules/codemirror/addon/dialog/dialog.js",
					"node_modules/codemirror/addon/selection/mark-selection.js",
					"node_modules/codemirror/addon/selection/active-line.js",
					"node_modules/codemirror/addon/selection/selection-pointer.js",
					"node_modules/codemirror/addon/lint/lint.js",
					"node_modules/codemirror/addon/lint/javascript-lint.js",
					"node_modules/codemirror/addon/tern/tern.js",
					"node_modules/codemirror/addon/runmode/colorize.js",
					"node_modules/codemirror/addon/runmode/runmode.js",
				],
				"codemirror.css": [
					"node_modules/codemirror/lib/codemirror.css",
					"node_modules/codemirror/theme/**/*.css",
					"node_modules/codemirror/addon/search/matchesonscrollbar.css",
					"node_modules/codemirror/addon/tern/tern.css",
					"node_modules/codemirror/addon/dialog/dialog.css",
					"node_modules/codemirror/addon/lint/lint.css",
					"node_modules/codemirror/addon/hint/show-hint.css",
				]
			}
		}),
	],
	module: {
		rules: [
			{
				test: /\.glsl$/i,
				use: "raw-loader",
			},
			{
				test: require.resolve("spine-runtimes/spine-ts/build/spine-threejs.js"),
				loader: "@shoutem/webpack-prepend-append",
				query: {
					append: "export {spine};"
				}
			}
		]
	},
	output: {
		filename: "bundle.js",
		path: output
	},
	module: {}
};
<commit_msg>Fix spine import<commit_after>const Path = require("path");
const Webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MergeIntoSingleFilePlugin = require("webpack-merge-and-include-globally");
const CopyPlugin = require("copy-webpack-plugin");

const context = Path.resolve(__dirname, ".");
const source = context + "/source";
const output = context + "/dist";

module.exports = {
	context: source,
	entry: source + "/editor/Main.js",
	target: "web",
	devtool: "inline-source-map",
	module: {
		rules: [
			{
				test: /\.glsl$/i,
				use: "raw-loader",
			},
			{
				test: /.*spine-threejs.*/,
				loader: "@shoutem/webpack-prepend-append",
				query: "{\"append\": \"export {spine};\"}"
			}
		]
	},
	output: {
		filename: "bundle.js",
		path: output
	},
	plugins: [
		new CopyPlugin({
			patterns: [
				{
					from: source + "/files",
					to: output + "/files",
					force: true
				}
			],
			options: {
				concurrency: 100,
			}
		}),
		new HtmlWebpackPlugin({template: source + "/editor/index.html", filename: "index.html"}),
		new Webpack.ProgressPlugin(),
		new Webpack.ProvidePlugin({
			THREE: "three",
			"window.THREE": "three"
		}),
		new MergeIntoSingleFilePlugin({
			files: {
				"styles.css": [
					"source/editor/style.css",
					"source/editor/theme/dark.css",
				],
				"jscolor.js": [
					"node_modules/@eastdesire/jscolor/jscolor.js",
				],
				"jshint.js": [
					"node_modules/jshint/dist/jshint.js"
				],
				"acorn.js": [
					"node_modules/acorn/dist/acorn.js",
					"node_modules/acorn-loose/dist/acorn-loose.js",
					"node_modules/acorn-walk/dist/walk.js"
				],
				"tern.js": [
					"node_modules/tern/lib/signal.js",
					"node_modules/tern/lib/tern.js",
					"node_modules/tern/lib/def.js",
					"node_modules/tern/lib/comment.js",
					"node_modules/tern/lib/infer.js",
					"node_modules/tern/plugin/doc_comment.js"
				],
				"codemirror.js": [
					"node_modules/codemirror/lib/codemirror.js",
					"node_modules/codemirror/keymap/sublime.js",
					"node_modules/codemirror/keymap/emacs.js",
					"node_modules/codemirror/keymap/vim.js",
					"node_modules/codemirror/mode/javascript/javascript.js",
					"node_modules/codemirror/mode/css/css.js",
					"node_modules/codemirror/mode/xml/xml.js",
					"node_modules/codemirror/mode/htmlmixed/htmlmixed.js",
					"node_modules/codemirror/addon/edit/closebrackets.js",
					"node_modules/codemirror/addon/edit/matchbrackets.js",
					"node_modules/codemirror/addon/scroll/annotatescrollbar.js",
					"node_modules/codemirror/addon/search/search.js",
					"node_modules/codemirror/addon/search/searchcursor.js",
					"node_modules/codemirror/addon/search/jump-to-line.js",
					"node_modules/codemirror/addon/search/match-highlighter.js",
					"node_modules/codemirror/addon/search/matchesonscrollbar.js",
					"node_modules/codemirror/addon/hint/show-hint.js",
					"node_modules/codemirror/addon/hint/anyword-hint.js",
					"node_modules/codemirror/addon/dialog/dialog.js",
					"node_modules/codemirror/addon/selection/mark-selection.js",
					"node_modules/codemirror/addon/selection/active-line.js",
					"node_modules/codemirror/addon/selection/selection-pointer.js",
					"node_modules/codemirror/addon/lint/lint.js",
					"node_modules/codemirror/addon/lint/javascript-lint.js",
					"node_modules/codemirror/addon/tern/tern.js",
					"node_modules/codemirror/addon/runmode/colorize.js",
					"node_modules/codemirror/addon/runmode/runmode.js",
				],
				"codemirror.css": [
					"node_modules/codemirror/lib/codemirror.css",
					"node_modules/codemirror/theme/**/*.css",
					"node_modules/codemirror/addon/search/matchesonscrollbar.css",
					"node_modules/codemirror/addon/tern/tern.css",
					"node_modules/codemirror/addon/dialog/dialog.css",
					"node_modules/codemirror/addon/lint/lint.css",
					"node_modules/codemirror/addon/hint/show-hint.css",
				]
			}
		}),
	]
};
<|endoftext|>


<commit_before>module.exports = {
	context: __dirname,
	entry: "./src/index.js",
	output: {
		filename: 'index.js',
		path: __dirname,
		libraryTarget: "commonjs2"
	},
	module: {
		loaders: [{
			test: /\.js?$/,
			exclude: /node_modules/,
			loader: 'babel-loader'
		}]
	},
	resolve: {
		extensions: ['.js']
	}
}<commit_msg>added loaders for scss loading<commit_after>module.exports = {
	context: __dirname,
	entry: "./src/index.js",
	output: {
		filename: 'index.js',
		path: __dirname,
		libraryTarget: "commonjs2"
	},
	module: {
		loaders: [{
			test: /\.js?$/,
			exclude: /node_modules/,
			loader: 'babel-loader'
		},{
			test: /\.scss$/,
			loaders: ["style-loader", "css-loader", "sass-loader"]
		}]
	},
	resolve: {
		extensions: ['.js']
	}
}<|endoftext|>


<commit_before>var webpack = require('webpack');
var path = require('path');
var WebpackCleanupPlugin = require('webpack-cleanup-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

var config = {
  cache: true,
  entry: {
    index: './client/index.js'
  },
  output: {
    path: 'public/build',
    filename: '[name].js',
    publicPath: '/build/'
  },
  module: {
    loaders: [
      {test: /\.js?/, loader: 'babel', exclude: /(node_modules|lib)/ },
      {test: /\.json$/, loader: 'json' },
      {test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css!less')},
      {test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css')},
      {test: /\.png$/, loader: 'url?limit=10000&mimetype=image/png'},
      {test: /\.(woff|woff2)$/, loader: 'url?limit=10000&mimetype=application/font-woff'},
      {test: /\.ttf$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
      {test: /\.(eot|mp3)$/, loader: 'file'},
      {test: /\.svg$/, loader: 'url?limit=10000&mimetype=image/svg+xml'},
      { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff&name=./[hash].[ext]" },
      { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
    ]
  },
  plugins: [
    // new WebpackCleanupPlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new ExtractTextPlugin('[name].css'),
    new CopyWebpackPlugin([
      {from: 'node_modules/midi/soundfont', to: 'soundfont'},
      {from: 'lib/abcjs/bin/abcjs_basic_2.4.0.js', to: '../../lib/abcjs.js'}
    ]),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': process.env.NPM_CONFIG_PRODUCTION ? '"production"' : '"development"'
    })
  ],
  resolve: {
    modules: ['node_modules', 'client', 'config'],
    alias: {
      'react-input-range-css': path.join(__dirname, './node_modules/react-input-range/dist/react-input-range.css')
    }
  }
};

module.exports = config;
<commit_msg>Update webpack config for production<commit_after>var webpack = require('webpack');
var path = require('path');
var WebpackCleanupPlugin = require('webpack-cleanup-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

var config = {
  cache: true,
  entry: {
    index: './client/index.js'
  },
  output: {
    path: 'public/build',
    filename: '[name].js',
    publicPath: '/build/'
  },
  module: {
    loaders: [
      {test: /\.js?/, loader: 'babel', exclude: /(node_modules|lib)/ },
      {test: /\.json$/, loader: 'json' },
      {test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css!less')},
      {test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css')},
      {test: /\.png$/, loader: 'url?limit=10000&mimetype=image/png'},
      {test: /\.(woff|woff2)$/, loader: 'url?limit=10000&mimetype=application/font-woff'},
      {test: /\.ttf$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
      {test: /\.(eot|mp3)$/, loader: 'file'},
      {test: /\.svg$/, loader: 'url?limit=10000&mimetype=image/svg+xml'},
      { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff&name=./[hash].[ext]" },
      { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
    ]
  },
  plugins: [
    // new WebpackCleanupPlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new ExtractTextPlugin('[name].css'),
    new CopyWebpackPlugin([
      {from: 'node_modules/midi/soundfont', to: 'soundfont'},
      {from: 'lib/abcjs/bin/abcjs_basic_2.4.0.js', to: '../../lib/abcjs.js'}
    ]),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': process.env.PRODUCTION ? '"production"' : '"development"'
    })
  ],
  resolve: {
    modules: ['node_modules', 'client', 'config'],
    alias: {
      'react-input-range-css': path.join(__dirname, './node_modules/react-input-range/dist/react-input-range.css')
    }
  }
};

module.exports = config;
<|endoftext|>


<commit_before>'use strict';

require('dotenv').load();

const webpack = require('webpack')
const HTMLPlugin = require('html-webpack-plugin')
const CleanPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const production = process.env.NODE_ENV === 'production'

let plugins = [
  new ExtractTextPlugin({ filename: 'bundle.css' }),
  new HTMLPlugin({template: `${__dirname}/app/index.html`}),
  new webpack.DefinePlugin({
    __API_URL__: JSON.stringify(process.env.API_URL),
    __DEBUG__: JSON.stringify(!production)
  })
]

if(production) {
  plugins = plugins.concat([
    new webpack.optimize.UglifyJsPlugin({
      mangle: true,
      compress: { warnings: false }
    }),
    new CleanPlugin()
  ])
}

module.exports = {
  entry: `${__dirname}/app/entry.js`,
  // devtool: production ? false : 'source-map',
  output: {
    filename: 'bundle.js',
    path: `${__dirname}/build`
  },
  plugins,
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.html$/,
        exclude: /node_modules/,
        use: ['html-loader']
      },
      {
        test: /\.(woff|ttf|svg|eot).*/,
        use: 'url-loader?limit=10000&name=image/[hash].[ext]'
      },
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract(
          {
            use: [
              {
                loader: 'css-loader',
                options: { sourceMap: true }
              },
              {
                loader: 'sass-loader',
                options: {
                  sourceMap: true,
                  includePaths: [`${__dirname}/app/scss`]
                }
              }
            ]
          }
        )
      }
    ]
  }
}
<commit_msg>more bug fixes<commit_after>'use strict';

require('dotenv').load();

const webpack = require('webpack')
const HTMLPlugin = require('html-webpack-plugin')
// const CleanPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const production = process.env.NODE_ENV === 'production'

let plugins = [
  new ExtractTextPlugin({ filename: 'bundle.css' }),
  new HTMLPlugin({template: `${__dirname}/app/index.html`}),
  new webpack.DefinePlugin({
    __API_URL__: JSON.stringify(process.env.API_URL),
    __DEBUG__: JSON.stringify(!production)
  })
]

// if(production) {
//   plugins = plugins.concat([
//     new webpack.optimize.UglifyJsPlugin({
//       mangle: true,
//       compress: { warnings: false }
//     }),
//     new CleanPlugin()
//   ])
// }

module.exports = {
  entry: `${__dirname}/app/entry.js`,
  // devtool: production ? false : 'source-map',
  output: {
    filename: 'bundle.js',
    path: `${__dirname}/build`
  },
  plugins,
  module: {
    loaders: [
      {
        test: /\.js$/,
        // exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.html$/,
        exclude: /node_modules/,
        use: ['html-loader']
      },
      {
        test: /\.(woff|ttf|svg|eot).*/,
        use: 'url-loader?limit=10000&name=image/[hash].[ext]'
      },
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract(
          {
            use: [
              {
                loader: 'css-loader',
                options: { sourceMap: true }
              },
              {
                loader: 'sass-loader',
                options: {
                  sourceMap: true,
                  includePaths: [`${__dirname}/app/scss`]
                }
              }
            ]
          }
        )
      }
    ]
  }
}
<|endoftext|>


<commit_before>var path = require('path');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var extractPlugin = new ExtractTextPlugin({
    filename: 'css/main.css'
});

module.exports = {
    entry: {
        app: './src/js/index.js'
    },
    output: {
        filename: 'js/[name].js',
        path: path.resolve(__dirname, 'dist')
    },
    devtool: 'source-map',
    module: {
        rules: [
            /**
             * Copy html file as layout
             */
            {
                test: /\.html$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]'
                        }
                    }
                ]
            },
            /**
             * Transpile es2016 into es2015 for compatibility
             */
            {
                test: /\.js$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: ['es2015']
                        }
                    }
                ]
            },
            /**
             * Transpile sass into css file
             */
            {
                test: /\.scss$/,
                use: extractPlugin.extract({
                    use: [
                        {
                            loader: 'css-loader',
                            options: {
                                sourceMap: true
                            }
                        },
                        {
                            loader: 'sass-loader',
                            options: {
                                sourceMap: true
                            }
                        }
                    ]
                })
            },
            /**
             * Copy fonts file
             */
            {
                test: /\.(eot|woff2|woff|ttf|svg)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]',
                            outputPath: 'fonts/',
                            publicPath: '../'
                        }
                    }
                ]
            }
        ]
    },
    plugins: [
        // cleanup dist folder each build cycle
        new CleanWebpackPlugin(['dist']),
        // extract text into separate file
        extractPlugin
    ],
    resolve: {
        alias: {
            vue: 'vue/dist/vue.js'
        }
    }
};
<commit_msg>cleanup dist forder only when build for production<commit_after>var path = require('path');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var extractPlugin = new ExtractTextPlugin({
    filename: 'css/main.css'
});

var config = {
    entry: {
        app: './src/js/index.js'
    },
    output: {
        filename: 'js/[name].js',
        path: path.resolve(__dirname, 'dist')
    },
    devtool: 'source-map',
    module: {
        rules: [
            /**
             * Copy html file as layout
             */
            {
                test: /\.html$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]'
                        }
                    }
                ]
            },
            /**
             * Transpile es2016 into es2015 for compatibility
             */
            {
                test: /\.js$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: ['es2015']
                        }
                    }
                ]
            },
            /**
             * Transpile sass into css file
             */
            {
                test: /\.scss$/,
                use: extractPlugin.extract({
                    use: [
                        {
                            loader: 'css-loader',
                            options: {
                                sourceMap: true
                            }
                        },
                        {
                            loader: 'sass-loader',
                            options: {
                                sourceMap: true
                            }
                        }
                    ]
                })
            },
            /**
             * Copy fonts file
             */
            {
                test: /\.(eot|woff2|woff|ttf|svg)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]',
                            outputPath: 'fonts/',
                            publicPath: '../'
                        }
                    }
                ]
            }
        ]
    },
    plugins: [
        // extract text into separate file
        extractPlugin
    ],
    resolve: {
        alias: {
            vue: 'vue/dist/vue.js'
        }
    }
};

if (process.env.NODE_ENV === 'production') {
    // cleanup only when build for production
    config.plugins.push(new CleanWebpackPlugin(['dist']));
}

module.exports = config;
<|endoftext|>


<commit_before>/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Karl STEIN
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

const path = require("path");
const Package = require("./package.json");
const isProd = process.argv.indexOf("-p") !== -1;
const filename = Package.name + (isProd ? ".min" : "");

module.exports = {
    entry: {
        bundle: path.join(__dirname, `src/jk-router.js`)
    },
    output: {
        libraryTarget: "umd",
        path: path.join(__dirname, "dist"),
        filename: `${filename}.js`
    },
    resolve: {
        extensions: [".js"],
        modules: [path.join(__dirname, "src"), "node_modules"]
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            }
        ]
    }
};
<commit_msg>Fixes path separator<commit_after>/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Karl STEIN
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

const path = require("path");
const Package = require("./package.json");
const isProd = process.argv.indexOf("-p") !== -1;
const filename = Package.name + (isProd ? ".min" : "");

module.exports = {
    entry: {
        bundle: path.join(__dirname, "src", `${filename}.js`)
    },
    output: {
        libraryTarget: "umd",
        path: path.join(__dirname, "dist"),
        filename: `${filename}.js`
    },
    resolve: {
        extensions: [".js"],
        modules: [path.join(__dirname, "src"), "node_modules"]
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            }
        ]
    }
};
<|endoftext|>


<commit_before>'use strict';
require('babel-loader');
require('babel-preset-es2015');
require('babel-preset-react');
require('babel-preset-stage-1');
require('css-loader');
require('style-loader');
require('autoprefixer-loader');
require('exports-loader');
require('imports-loader');
require('whatwg-fetch');
var webpack = require('webpack');
var precss = require('precss');
var autoprefixer = require('autoprefixer');

module.exports = {
  entry: {
    app: 'App'
  },
  output: {
    filename: '[name].bundle.js',
    chunkFilename: '[id].bundle.js',
    path: 'app/public/js/',
    publicPath: '/js/'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /(node_modules|bower_components)/,
        query: {
          presets: ['react', 'es2015', 'stage-1'],
        }
      },
      {test: /\.css/, loader: 'style-loader!css-loader!postcss-loader'},
      {test: require.resolve('react'), loader: 'expose?React' }
    ]
  },
  plugins: [
    new webpack.ProvidePlugin({
      'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
    }),
  ],
  resolve: {
    alias: {
    },
    root: [__dirname + '/app/client']
  },
  postcss: function() {
    return [precss, autoprefixer];
  }
};
<commit_msg>Fix webpack.config.js<commit_after>'use strict';
require('babel-loader');
require('babel-preset-es2015');
require('babel-preset-react');
require('babel-preset-stage-1');
require('css-loader');
require('style-loader');
require('postcss-loader');
require('exports-loader');
require('imports-loader');
require('whatwg-fetch');
var webpack = require('webpack');
var precss = require('precss');
var autoprefixer = require('autoprefixer');

module.exports = {
  entry: {
    app: 'App'
  },
  output: {
    filename: '[name].bundle.js',
    chunkFilename: '[id].bundle.js',
    path: 'app/public/js/',
    publicPath: '/js/'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /(node_modules|bower_components)/,
        query: {
          presets: ['react', 'es2015', 'stage-1'],
        }
      },
      {test: /\.css/, loader: 'style-loader!css-loader!postcss-loader'},
      {test: require.resolve('react'), loader: 'expose?React' }
    ]
  },
  plugins: [
    new webpack.ProvidePlugin({
      'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
    }),
  ],
  resolve: {
    alias: {
    },
    root: [__dirname + '/app/client']
  },
  postcss: function() {
    return [precss, autoprefixer];
  }
};
<|endoftext|>


<commit_before>const webpack = require('webpack');
const path = require('path');
const entries = {};

require('glob').sync('./resources/assets/js/*.js').map(entry => {
    const name = entry.match('^.+/(.+?)\\.js$')[1];
    entries[name] = entry;
});

module.exports = {
    entry: entries,
    output: {
        path: path.join(__dirname, '/public'),
        filename: './assets/[name].[hash].js',
        hashDigestLength: 8,
    },
    resolve: {
        alias: {
            vue: 'vue/dist/vue.esm.js',
        },
        extensions: [ '.js', '.vue' ],
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                use: [ 'babel-loader' ],
                exclude: /node_modules/,
            },
            {
                test: /\.vue$/,
                use: [ 'vue-loader' ],
            },
            {
                test: /\.(js|vue)$/,
                use: [ 'eslint-loader' ],
                exclude: /node_modules/,
                enforce: 'pre',
            },
            {
                test: /\.s?css$/,
                use: [ 'style-loader', 'css-loader', 'postcss-loader', 'sass-loader' ],
            },
            {
                test: /\.(woff2?|ttf|eot|svg|png)(\?v=[\d.]+|\?[\s\S]+)?$/,
                use: [ 'file-loader?name=/assets/[name].[ext]' ],
            },
        ],
    },
    optimization: {
        runtimeChunk: {
            name: 'vendor',
        },
        splitChunks: {
            name: 'vendor',
            chunks: 'initial',
        },
    },
    performance: {
        maxEntrypointSize: 1024000,
        maxAssetSize: 1024000,
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
        }),
        new webpack.ProgressPlugin(percentage => {
            if (percentage == 1) {
                require('child_process').exec('./artisan view:clear');
            }
        }),
        new (require('clean-webpack-plugin'))([
            path.join(__dirname, '/public/assets/*'),
        ]),
        new (require('browser-sync-webpack-plugin'))({
            proxy: process.env.PROXY_HOST || 'localhost',
            files: './public/assets/*',
            ghostMode: {
                clicks: false,
                scroll: false,
                location: false,
                forms: false,
            },
            open: false,
            notify: false,
        }),
        new (require('vue-loader/lib/plugin'))(),
    ],
};
<commit_msg>clean-webpack-plugin 2.x 系に対応<commit_after>const webpack = require('webpack');
const path = require('path');
const entries = {};

require('glob').sync('./resources/assets/js/*.js').map(entry => {
    const name = entry.match('^.+/(.+?)\\.js$')[1];
    entries[name] = entry;
});

module.exports = {
    entry: entries,
    output: {
        path: path.join(__dirname, '/public'),
        filename: './assets/[name].[hash].js',
        hashDigestLength: 8,
    },
    resolve: {
        alias: {
            vue: 'vue/dist/vue.esm.js',
        },
        extensions: [ '.js', '.vue' ],
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                use: [ 'babel-loader' ],
                exclude: /node_modules/,
            },
            {
                test: /\.vue$/,
                use: [ 'vue-loader' ],
            },
            {
                test: /\.(js|vue)$/,
                use: [ 'eslint-loader' ],
                exclude: /node_modules/,
                enforce: 'pre',
            },
            {
                test: /\.s?css$/,
                use: [ 'style-loader', 'css-loader', 'postcss-loader', 'sass-loader' ],
            },
            {
                test: /\.(woff2?|ttf|eot|svg|png)(\?v=[\d.]+|\?[\s\S]+)?$/,
                use: [ 'file-loader?name=/assets/[name].[ext]' ],
            },
        ],
    },
    optimization: {
        runtimeChunk: {
            name: 'vendor',
        },
        splitChunks: {
            name: 'vendor',
            chunks: 'initial',
        },
    },
    performance: {
        maxEntrypointSize: 1024000,
        maxAssetSize: 1024000,
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
        }),
        new webpack.ProgressPlugin(percentage => {
            if (percentage == 1) {
                require('child_process').exec('./artisan view:clear');
            }
        }),
        new (require('clean-webpack-plugin'))({
            cleanOnceBeforeBuildPatterns: [
                'assets/*.{ttf,eot,woff*,js,css,jp*g,png,gif}',
            ],
            verbose: true,
        }),
        new (require('browser-sync-webpack-plugin'))({
            proxy: process.env.PROXY_HOST || 'localhost',
            files: './public/assets/*',
            ghostMode: {
                clicks: false,
                scroll: false,
                location: false,
                forms: false,
            },
            open: false,
            notify: false,
        }),
        new (require('vue-loader/lib/plugin'))(),
    ],
};
<|endoftext|>


<commit_before>// For info about this file refer to webpack and webpack-hot-middleware documentation
// Rather than having hard coded webpack.config.js for each environment, this
// file generates a webpack config for the environment passed to the getConfig method.
import webpack from 'webpack';
import path from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';

const developmentEnvironment = 'development' ;
const productionEnvironment = 'production';
const testEnvironment = 'test';

const getPlugins = function (env) {
  const GLOBALS = {
    'process.env.NODE_ENV': JSON.stringify(env),
    __DEV__: env === developmentEnvironment
  };

  const plugins = [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin(GLOBALS) //Tells React to build in prod mode. https://facebook.github.io/react/downloads.html
  ];

  switch (env) {
    case productionEnvironment:
      plugins.push(new ExtractTextPlugin('styles.css'));
      plugins.push(new webpack.optimize.DedupePlugin());
      plugins.push(new webpack.optimize.UglifyJsPlugin());
      break;

    case developmentEnvironment:
      plugins.push(new webpack.HotModuleReplacementPlugin());
      plugins.push(new webpack.NoErrorsPlugin());
      break;
  }

  return plugins;
};

const getEntry = function (env) {
  const entry = [];

  if (env === developmentEnvironment ) { // only want hot reloading when in dev.
    entry.push('webpack-hot-middleware/client');
  }

  entry.push('./src/index');

  return entry;
};

const getLoaders = function (env) {
  const loaders = [{ test: /\.js$/, include: path.join(__dirname, 'src'), loaders: ['babel', 'eslint'] }];

  if (env === productionEnvironment ) {
    // generate separate physical stylesheet for production build using ExtractTextPlugin. This provides separate caching and avoids a flash of unstyled content on load.
    loaders.push({test: /(\.css|\.scss)$/, loader: ExtractTextPlugin.extract("css?sourceMap!sass?sourceMap")});
  } else {
    loaders.push({test: /(\.css|\.scss)$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']});
  }

  return loaders;
};

function getConfig(env) {
  return {
    debug: true,
    devtool: env === productionEnvironment  ? 'source-map' : 'cheap-module-eval-source-map', // more info:https://webpack.github.io/docs/build-performance.html#sourcemaps and https://webpack.github.io/docs/configuration.html#devtool
    noInfo: true, // set to false to see a list of every file being bundled.
    entry: getEntry(env),
    target: env === testEnvironment ? 'node' : 'web', // necessary per https://webpack.github.io/docs/testing.html#compile-and-test
    output: {
      path: __dirname + '/dist', // Note: Physical files are only output by the production build task `npm run build`.
      publicPath: '',
      filename: 'bundle.js'
    },
    plugins: getPlugins(env),
    module: {
      loaders: getLoaders(env)
    }
  };
}

export default getConfig;
<commit_msg>* Tell webpack to resolve .jsx .scss .js and .json files automatically. * Tell the CSS loader to include modules (@import ...)<commit_after>// For info about this file refer to webpack and webpack-hot-middleware documentation
// Rather than having hard coded webpack.config.js for each environment, this
// file generates a webpack config for the environment passed to the getConfig method.
import webpack from 'webpack';
import path from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';

const developmentEnvironment = 'development' ;
const productionEnvironment = 'production';
const testEnvironment = 'test';

const getPlugins = function (env) {
  const GLOBALS = {
    'process.env.NODE_ENV': JSON.stringify(env),
    __DEV__: env === developmentEnvironment
  };

  const plugins = [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin(GLOBALS) //Tells React to build in prod mode. https://facebook.github.io/react/downloads.html
  ];

  switch (env) {
    case productionEnvironment:
      plugins.push(new ExtractTextPlugin('styles.css'));
      plugins.push(new webpack.optimize.DedupePlugin());
      plugins.push(new webpack.optimize.UglifyJsPlugin());
      break;

    case developmentEnvironment:
      plugins.push(new webpack.HotModuleReplacementPlugin());
      plugins.push(new webpack.NoErrorsPlugin());
      break;
  }

  return plugins;
};

const getEntry = function (env) {
  const entry = [];

  if (env === developmentEnvironment ) { // only want hot reloading when in dev.
    entry.push('webpack-hot-middleware/client');
  }

  entry.push('./src/index');

  return entry;
};

const getLoaders = function (env) {
  const loaders = [{ test: /\.js$/, include: path.join(__dirname, 'src'), loaders: ['babel', 'eslint'] }];

  if (env === productionEnvironment ) {
    // generate separate physical stylesheet for production build using ExtractTextPlugin. This provides separate caching and avoids a flash of unstyled content on load.
    loaders.push({test: /(\.css|\.scss)$/, loader: ExtractTextPlugin.extract("css?sourceMap!sass?sourceMap")});
  } else {
    loaders.push({test: /(\.css|\.scss)$/, loaders: ['style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'sass?sourceMap']});
  }

  return loaders;
};

function getConfig(env) {
  return {
    debug: true,
    devtool: env === productionEnvironment  ? 'source-map' : 'cheap-module-eval-source-map', // more info:https://webpack.github.io/docs/build-performance.html#sourcemaps and https://webpack.github.io/docs/configuration.html#devtool
    noInfo: true, // set to false to see a list of every file being bundled.
    entry: getEntry(env),
    target: env === testEnvironment ? 'node' : 'web', // necessary per https://webpack.github.io/docs/testing.html#compile-and-test
    output: {
      path: __dirname + '/dist', // Note: Physical files are only output by the production build task `npm run build`.
      publicPath: '',
      filename: 'bundle.js'
    },
    resolve: {
      extensions: ['', '.jsx', '.scss', '.js', '.json']
    },
    plugins: getPlugins(env),
    module: {
      loaders: getLoaders(env)
    }
  };
}

export default getConfig;
<|endoftext|>


<commit_before>var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  progress: true,
  entry: {
    uskin: './js/uskin.js',
    css: './css/uskin.less'
  },
  output: {
    path: './dist/js',
    filename: '[hash:6].[name].min.js',
    library: 'uskin',
    libraryTarget: 'umd'
  },
  externals: {
    react: {
      root: 'React',
      commonjs2: 'react',
      commonjs: 'react',
      amd: 'react'
    }
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [{
      test: /\.js|jsx$/,
      exclude: /node_modules|__tests__/,
      loader: 'babel-loader',
      query: {
        cacheDirectory: true
      }
    }, {
      test: /\.json$/,
      loader: 'json-loader'
    }, {
      test: /\.less$/,
      loader: ExtractTextPlugin.extract(
        'css?sourceMap&-minimize!' + 'autoprefixer-loader!' + 'less?sourceMap'
      )
    }, {
      test: /\.css$/,
      loader: ExtractTextPlugin.extract(
        'css?sourceMap&-minimize!' + 'autoprefixer-loader'
      )
    }, {
      test: /\.(woff|svg|eot|ttf)\??.*$/,
      loader: 'url?limit=1000&name=./fonts/[hash:8].icon.[ext]'
    }]
  },
  plugins: []
};
<commit_msg>update build script<commit_after>var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  progress: true,
  entry: {
    uskin: './js/uskin.js',
    css: './css/uskin.less'
  },
  output: {
    path: './dist/js',
    filename: '[hash:6].[name].min.js',
    library: 'uskin',
    libraryTarget: 'umd'
  },
  externals: {
    react: {
      root: 'React',
      commonjs2: 'react',
      commonjs: 'react',
      amd: 'react'
    }
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [{
      test: /\.js|jsx$/,
      exclude: /node_modules|__tests__/,
      loader: 'babel-loader',
      query: {
        cacheDirectory: process.env.NODE_ENV !== 'production'
      }
    }, {
      test: /\.json$/,
      loader: 'json-loader'
    }, {
      test: /\.less$/,
      loader: ExtractTextPlugin.extract(
        'css?sourceMap&-minimize!' + 'autoprefixer-loader!' + 'less?sourceMap'
      )
    }, {
      test: /\.css$/,
      loader: ExtractTextPlugin.extract(
        'css?sourceMap&-minimize!' + 'autoprefixer-loader'
      )
    }, {
      test: /\.(woff|svg|eot|ttf)\??.*$/,
      loader: 'url?limit=1000&name=./fonts/[hash:8].icon.[ext]'
    }]
  },
  plugins: []
};
<|endoftext|>


<commit_before>const path = require('path');

module.exports = {
    mode: 'production',
    entry: './src/enum.js',
    output: {
        filename: 'enum.js',
        path: path.resolve(__dirname, 'dist'),
        library: 'Enum',
        libraryTarget: 'umd'
    },
    module: {
        rules: [{
            test: /\.js$/,
            use: 'babel-loader'
        }]
    }
};
<commit_msg>fix bug<commit_after>const path = require('path');

module.exports = {
    mode: 'production',
    entry: './src/enum.js',
    output: {
        filename: 'enum.js',
        path: path.resolve(__dirname, 'dist'),
        library: 'Enum',
        libraryTarget: 'umd',
        globalObject: 'this'
    },
    module: {
        rules: [{
            test: /\.js$/,
            use: 'babel-loader'
        }]
    }
};
<|endoftext|>


<commit_before>'use strict';

const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');

let appEntry;
let devtool;
let plugins;

const htmlTemplate = new HtmlWebpackPlugin({
  title: 'Relay Starter Kit - Integrated with Relay, GraphQL, Express, ES6/ES7, JSX, Webpack, Babel, Material Design Lite, and PostCSS',
  template: './client/index.html',
  mobile: true,
  inject: false
});
const favIcon = new FaviconsWebpackPlugin('./client/assets/logo.png');

if (process.env.NODE_ENV === 'production') {
  appEntry = [path.join(__dirname, 'client/index.js')];
  devtool = 'source-map';
  plugins = [
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js'}),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
        screw_ie8: true
      }
    }),
    htmlTemplate,
    favIcon
  ];
} else {
  appEntry = [
    // activate HMR for React
    'react-hot-loader/patch',
    path.join(__dirname, 'client/index.js'),
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server'
  ];
  devtool = 'eval';
  plugins = [
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js'}),
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.DefinePlugin({
      __DEV__: true
    }),
    htmlTemplate,
    favIcon
  ];
}

module.exports = {
  entry: {
    app: appEntry,
    vendor: ['react', 'react-dom', 'react-mdl', 'react-relay', 'react-router', 'react-router-relay']
  },
  output: {
    path: path.join(__dirname, 'build'),
    publicPath: '/',
    filename: '[name].js'
  },
  devtool,
  module: {
    rules: [{
      test: /\.jsx?$/,
      use: 'babel-loader',
      exclude: /node_modules/
    }, {
      test: /\.css$/,
      use: [
        'style-loader',
        'css-loader'
      ],
    }, {
      test: /\.scss$/,
      use: [
        'style-loader',
        {
          loader: 'css-loader',
          options: {
            modules: true,
            importLoaders: 1,
            localIdentName: "[name]__[local]___[hash:base64:5]",
          }
        },
        {
          loader: 'postcss-loader',
          options: {
            //https://github.com/postcss/postcss-loader/issues/164
            // use ident if passing a function
            ident: 'postcss', plugins: () => [
              require('precss'),
              require('autoprefixer')
            ]
          }

        }
      ]
    }, {
      test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/,
      use: [
        {
          loader: 'url-loader',
          options: {
            limit: 1000,
            name: "assets/[hash].[ext]"
          }
        }
      ]
    }]
  },
  plugins
};
<commit_msg>Add named NamedModulesPlugin() to webpack, Let's us know the name of the component being updated<commit_after>'use strict';

const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');

let appEntry;
let devtool;
let plugins;

const htmlTemplate = new HtmlWebpackPlugin({
  title: 'Relay Starter Kit - Integrated with Relay, GraphQL, Express, ES6/ES7, JSX, Webpack, Babel, Material Design Lite, and PostCSS',
  template: './client/index.html',
  mobile: true,
  inject: false
});
const favIcon = new FaviconsWebpackPlugin('./client/assets/logo.png');

if (process.env.NODE_ENV === 'production') {
  appEntry = [path.join(__dirname, 'client/index.js')];
  devtool = 'source-map';
  plugins = [
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js'}),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
        screw_ie8: true
      }
    }),
    htmlTemplate,
    favIcon
  ];
} else {
  appEntry = [
    // activate HMR for React
    'react-hot-loader/patch',
    path.join(__dirname, 'client/index.js'),
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server'
  ];
  devtool = 'eval';
  plugins = [
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js'}),
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.DefinePlugin({
      __DEV__: true
    }),
    htmlTemplate,
    favIcon
  ];
}

module.exports = {
  entry: {
    app: appEntry,
    vendor: ['react', 'react-dom', 'react-mdl', 'react-relay', 'react-router', 'react-router-relay']
  },
  output: {
    path: path.join(__dirname, 'build'),
    publicPath: '/',
    filename: '[name].js'
  },
  devtool,
  module: {
    rules: [{
      test: /\.jsx?$/,
      use: 'babel-loader',
      exclude: /node_modules/
    }, {
      test: /\.css$/,
      use: [
        'style-loader',
        'css-loader'
      ],
    }, {
      test: /\.scss$/,
      use: [
        'style-loader',
        {
          loader: 'css-loader',
          options: {
            modules: true,
            importLoaders: 1,
            localIdentName: "[name]__[local]___[hash:base64:5]",
          }
        },
        {
          loader: 'postcss-loader',
          options: {
            //https://github.com/postcss/postcss-loader/issues/164
            // use ident if passing a function
            ident: 'postcss', plugins: () => [
              require('precss'),
              require('autoprefixer')
            ]
          }

        }
      ]
    }, {
      test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/,
      use: [
        {
          loader: 'url-loader',
          options: {
            limit: 1000,
            name: "assets/[hash].[ext]"
          }
        }
      ]
    }]
  },
  plugins
};
<|endoftext|>


<commit_before>const {resolve} = require('path');
const {
  optimize: {ModuleConcatenationPlugin},
  DefinePlugin,
  NamedModulesPlugin,
  HotModuleReplacementPlugin,
  NoEmitOnErrorsPlugin,
} = require('webpack');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const CleanPlugin = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HTMLPlugin = require('html-webpack-plugin');
const BabelMinifyPlugin = require('babel-minify-webpack-plugin');
const OptimizeJSPlugin = require('optimize-js-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const OfflinePlugin = require('offline-plugin');

const {extract} = ExtractTextPlugin;

const src = 'src';
const dest = 'app';
const clean = [dest];
const copy = [
  {
    from: 'static',
  },
];

function config({report, dev, devServer} = {}) {
  const env = dev ? 'development' : 'production';

  return {
    devtool: dev ? 'eval-source-map' : 'hidden-source-map',
    entry: [
      ...dev
        ? [
          `webpack-dev-server/client?${devServer}`,
          'webpack/hot/only-dev-server',
          'react-hot-loader/patch',
        ]
        : [],
      `./${src}/index.jsx`,
    ],
    output: {
      path: resolve(__dirname, dest),
      filename: `bundle${dev ? '' : '.[chunkhash]'}.js`,
    },
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          include: resolve(__dirname, src),
          loader: 'babel-loader',
          options: {
            cacheDirectory: dev,
            forceEnv: env,
          },
        },
        {
          test: /\.css$/,
          include: resolve(__dirname, src),
          use: dev
            ? [
              'style-loader',
              {
                loader: 'css-loader',
                options: {
                  sourceMap: true,
                  modules: true,
                  localIdentName: '[name]__[local]___[hash:base64:5]',
                },
              },
            ]
            : extract({
              fallback: 'style-loader',
              use: {
                loader: 'css-loader',
                options: {
                  sourceMap: true,
                  modules: true,
                  localIdentName: '[name]__[local]___[hash:base64:5]',
                },
              },
            }),
        },
      ],
    },
    plugins: [
      new CleanPlugin(clean),
      new CopyPlugin(copy),
      new HTMLPlugin({
        template: `${src}/template.ejs`,
        inject: false,
        minify: {
          removeComments: true,
          collapseWhitespace: true,
          minifyCSS: true,
          minifyJS: true,
        },
      }),
      new DefinePlugin({
        'process.env.NODE_ENV': JSON.stringify(env),
      }),
      ...dev
        ? [
          new NamedModulesPlugin(),
          new HotModuleReplacementPlugin(),
          new NoEmitOnErrorsPlugin(),
          new BundleAnalyzerPlugin({
            analyzerHost: '0.0.0.0',
            openAnalyzer: false,
          }),
        ]
        : [
          new ModuleConcatenationPlugin(),
          new BabelMinifyPlugin(),
          new OptimizeJSPlugin(),
          new ExtractTextPlugin({
            filename: 'style.[contenthash].css',
            allChunks: true,
          }),
          ...report
            ? [
              new BundleAnalyzerPlugin({
                analyzerMode: 'static',
              }),
            ]
            : [],
          new OfflinePlugin(),
        ],
    ],
    resolve: {
      extensions: ['.js', '.jsx', '.json'],
    },
  };
}

module.exports = config;
<commit_msg>Small fixes<commit_after>const {resolve} = require('path');
const {
  optimize: {ModuleConcatenationPlugin},
  DefinePlugin,
  NamedModulesPlugin,
  HotModuleReplacementPlugin,
  NoEmitOnErrorsPlugin,
} = require('webpack');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const CleanPlugin = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HTMLPlugin = require('html-webpack-plugin');
const BabelMinifyPlugin = require('babel-minify-webpack-plugin');
const OptimizeJSPlugin = require('optimize-js-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const OfflinePlugin = require('offline-plugin');

const {extract} = ExtractTextPlugin;

const src = 'src';
const dest = 'app';
const clean = [dest];
const copy = [
  {
    from: 'static',
  },
];

function config({dev, devServer, report} = {}) {
  const env = dev ? 'development' : 'production';

  return {
    devtool: dev ? 'eval-source-map' : 'hidden-source-map',
    entry: [
      ...dev
        ? [
          `webpack-dev-server/client?${devServer}`,
          'webpack/hot/only-dev-server',
          'react-hot-loader/patch',
        ]
        : [],
      `./${src}/index.jsx`,
    ],
    output: {
      path: resolve(__dirname, dest),
      filename: `bundle${dev ? '' : '.[chunkhash]'}.js`,
    },
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          include: resolve(__dirname, src),
          loader: 'babel-loader',
          options: {
            cacheDirectory: dev,
            forceEnv: env,
          },
        },
        {
          test: /\.css$/,
          include: resolve(__dirname, src),
          use: dev
            ? [
              'style-loader',
              {
                loader: 'css-loader',
                options: {
                  sourceMap: true,
                  modules: true,
                  localIdentName: '[name]__[local]___[hash:base64:5]',
                },
              },
            ]
            : extract({
              fallback: 'style-loader',
              use: {
                loader: 'css-loader',
                options: {
                  sourceMap: true,
                  modules: true,
                  localIdentName: '[name]__[local]___[hash:base64:5]',
                },
              },
            }),
        },
      ],
    },
    plugins: [
      new CleanPlugin(clean),
      new CopyPlugin(copy),
      new HTMLPlugin({
        template: `${src}/template.ejs`,
        inject: false,
        minify: {
          removeComments: true,
          collapseWhitespace: true,
          minifyCSS: true,
          minifyJS: true,
        },
      }),
      new DefinePlugin({
        'process.env.NODE_ENV': JSON.stringify(env),
      }),
      ...dev
        ? [
          new NamedModulesPlugin(),
          new HotModuleReplacementPlugin(),
          new NoEmitOnErrorsPlugin(),
          new BundleAnalyzerPlugin({
            analyzerHost: '0.0.0.0',
            openAnalyzer: false,
          }),
        ]
        : [
          new ModuleConcatenationPlugin(),
          new BabelMinifyPlugin(),
          new OptimizeJSPlugin(),
          new ExtractTextPlugin({
            filename: 'style.[contenthash].css',
            allChunks: true,
          }),
          ...report
            ? [
              new BundleAnalyzerPlugin({
                analyzerMode: 'static',
              }),
            ]
            : [],
          new OfflinePlugin(),
        ],
    ],
    resolve: {
      extensions: ['.js', '.jsx', '.json'],
    },
  };
}

module.exports = config;
<|endoftext|>


<commit_before>module.exports = {
  entry: ['./app/main.jsx'],
  output: {
    path: './build',
    filename: 'bundle.js',
    pathinfo: true
  },
  module: {
    loaders: [
      {
        test: /\.jsx$/,
        exclude: /node_modules/,
        loader: 'babel'
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        loader: 'style!css!sass'
      },
      {
        test: /\.svg$/,
        loader: 'file-loader'
      }
    ]
  },
  devtool: 'source-map',
  devServer: {
    contentBase: './build',
    hot: true,
    progress: true,
    colors: true,
  }
};
<commit_msg>Convert .js files with babel<commit_after>module.exports = {
  entry: ['./app/main.jsx'],
  output: {
    path: './build',
    filename: 'bundle.js',
    pathinfo: true
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel'
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        loader: 'style!css!sass'
      },
      {
        test: /\.svg$/,
        loader: 'file-loader'
      }
    ]
  },
  devtool: 'source-map',
  devServer: {
    contentBase: './build',
    hot: true,
    progress: true,
    colors: true,
  }
};
<|endoftext|>


<commit_before>var webpack = require('webpack');

module.exports = {
    entry: [
        './app/app.jsx'
    ],
    output: {
        path: __dirname,
        filename: './public/bundle.js'
    },
    resolve: {
        root: __dirname,
        alias: {
            Main: 'app/components/Main.jsx',
            applicationStyles: 'app/styles/app.css'
        },
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015']
                },
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/
            }
        ]
    },
    devtool: 'cheap-module-eval-source-map'
};<commit_msg>added modulesDirectory<commit_after>var webpack = require('webpack');

module.exports = {
    entry: [
        './app/app.jsx'
    ],
    output: {
        path: __dirname,
        filename: './public/bundle.js'
    },
    resolve: {
        root: __dirname,
        modulesDirectories: [
            'node_modules',
            './app/components',
        ],
        alias: {
            applicationStyles: 'app/styles/app.css'
        },
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015']
                },
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/
            }
        ]
    },
    devtool: 'cheap-module-eval-source-map'
};<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const {optimize} = webpack;
const {UglifyJsPlugin} = optimize;

const dir = './client';

const {env} = process;
const isDev = env.NODE_ENV === 'development';

const dist = path.resolve(__dirname, 'dist');
const distDev = path.resolve(__dirname, 'dist-dev');
const devtool = isDev ? 'eval' : 'source-map';
const notEmpty = (a) => a;
const clean = (array) => array.filter(notEmpty);

const plugins = clean([
    !isDev && new UglifyJsPlugin({
        sourceMap: true,
        comments: false,
    }),
    new webpack.optimize.CommonsChunkPlugin({
        name: 'cloudcmd',
        filename: 'cloudcmd.js',
    }),
]);

module.exports = {
    devtool,
    entry: {
        cloudcmd: `${dir}/cloudcmd.js`,
        edit: `${dir}/edit.js`,
        'edit-file': `${dir}/edit-file.js`,
        'edit-names': `${dir}/edit-names.js`,
        menu: `${dir}/menu.js`,
        view: `${dir}/view.js`,
        help: `${dir}/help.js`,
        markdown: `${dir}/markdown.js`,
        config: `${dir}/config.js`,
        contact: `${dir}/contact.js`,
        upload: `${dir}/upload.js`,
        operation: `${dir}/operation.js`,
        konsole: `${dir}/konsole.js`,
        cloud: `${dir}/cloud.js`,
        polyfill: `${dir}/polyfill.js`,
    },
    output: {
        filename: '[name].js',
        path: isDev ? distDev : dist,
        libraryTarget: 'umd'
    },
    plugins,
    externals: [
        externals
    ],
    module: {
        loaders: [{
            test: /\.js$/,
            exclude: /(node_)?modules/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015']
            }
        }
        ]
    }
};

function externals(context, request, fn) {
    if (!isDev)
        return fn();

    const list = [
        'es6-promise',
    ];

    if (list.includes(request))
        return fn(null, request);

    fn();
}
<commit_msg>chore(webpack) add "use strict"<commit_after>'use strict';

const path = require('path');
const webpack = require('webpack');
const {optimize} = webpack;
const {UglifyJsPlugin} = optimize;

const dir = './client';

const {env} = process;
const isDev = env.NODE_ENV === 'development';

const dist = path.resolve(__dirname, 'dist');
const distDev = path.resolve(__dirname, 'dist-dev');
const devtool = isDev ? 'eval' : 'source-map';
const notEmpty = (a) => a;
const clean = (array) => array.filter(notEmpty);

const plugins = clean([
    !isDev && new UglifyJsPlugin({
        sourceMap: true,
        comments: false,
    }),
    new webpack.optimize.CommonsChunkPlugin({
        name: 'cloudcmd',
        filename: 'cloudcmd.js',
    }),
]);

module.exports = {
    devtool,
    entry: {
        cloudcmd: `${dir}/cloudcmd.js`,
        edit: `${dir}/edit.js`,
        'edit-file': `${dir}/edit-file.js`,
        'edit-names': `${dir}/edit-names.js`,
        menu: `${dir}/menu.js`,
        view: `${dir}/view.js`,
        help: `${dir}/help.js`,
        markdown: `${dir}/markdown.js`,
        config: `${dir}/config.js`,
        contact: `${dir}/contact.js`,
        upload: `${dir}/upload.js`,
        operation: `${dir}/operation.js`,
        konsole: `${dir}/konsole.js`,
        cloud: `${dir}/cloud.js`,
        polyfill: `${dir}/polyfill.js`,
    },
    output: {
        filename: '[name].js',
        path: isDev ? distDev : dist,
        libraryTarget: 'umd'
    },
    plugins,
    externals: [
        externals
    ],
    module: {
        loaders: [{
            test: /\.js$/,
            exclude: /(node_)?modules/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015']
            }
        }
        ]
    }
};

function externals(context, request, fn) {
    if (!isDev)
        return fn();

    const list = [
        'es6-promise',
    ];

    if (list.includes(request))
        return fn(null, request);

    fn();
}
<|endoftext|>


<commit_before>/* eslint-env node, es6 */

'use strict';

const
  BASE_NAME = 'cssprefix',
  OBJECT_NAME = 'CSSPrefix',

  webpack = require('webpack'),
  path = require('path'),
  PKG = require('./package'),

  RULES = require('./webpack.config.rules.js'),

  BUILD = process.env.NODE_ENV === 'production',

  SRC_PATH = path.resolve(__dirname, 'src'),
  ENTRY_PATH = path.resolve(SRC_PATH, `${BASE_NAME}.js`),
  BUILD_PATH = BUILD ? __dirname : path.resolve(__dirname, 'test'),
  BUILD_FILE = `${BASE_NAME}${BUILD ? '.min' : ''}.js`;

module.exports = {
  entry: ENTRY_PATH,
  output: {
    path: BUILD_PATH,
    filename: BUILD_FILE,
    library: OBJECT_NAME,
    libraryTarget: 'var'
  },
  module: {rules: RULES},
  devtool: BUILD ? false : 'source-map',
  plugins: BUILD ? [
    new webpack.optimize.UglifyJsPlugin({compress: {warnings: true}}),
    new webpack.BannerPlugin({raw: true,
      banner: `/*! ${PKG.title || PKG.name} v${PKG.version} (c) ${PKG.author.name} ${PKG.homepage} */`})
  ] : []
};
<commit_msg>Change option for webpack.BannerPlugin<commit_after>/* eslint-env node, es6 */

'use strict';

const
  BASE_NAME = 'cssprefix',
  OBJECT_NAME = 'CSSPrefix',

  webpack = require('webpack'),
  path = require('path'),
  PKG = require('./package'),

  RULES = require('./webpack.config.rules.js'),

  BUILD = process.env.NODE_ENV === 'production',

  SRC_PATH = path.resolve(__dirname, 'src'),
  ENTRY_PATH = path.resolve(SRC_PATH, `${BASE_NAME}.js`),
  BUILD_PATH = BUILD ? __dirname : path.resolve(__dirname, 'test'),
  BUILD_FILE = `${BASE_NAME}${BUILD ? '.min' : ''}.js`;

module.exports = {
  entry: ENTRY_PATH,
  output: {
    path: BUILD_PATH,
    filename: BUILD_FILE,
    library: OBJECT_NAME,
    libraryTarget: 'var'
  },
  module: {rules: RULES},
  devtool: BUILD ? false : 'source-map',
  plugins: BUILD ? [
    new webpack.optimize.UglifyJsPlugin({compress: {warnings: true}}),
    new webpack.BannerPlugin(
      `${PKG.title || PKG.name} v${PKG.version} (c) ${PKG.author.name} ${PKG.homepage}`)
  ] : []
};
<|endoftext|>


<commit_before>const Encore = require('@symfony/webpack-encore');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const PurgecssPlugin = require('purgecss-webpack-plugin');
const glob = require('glob-all');
const path = require('path');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

const makeConfig = (BROWSERSLIST_ENV) => {
    const DEFAULT_BROWSER_TARGET = 'modern';
    const BROWSER_TARGET = BROWSERSLIST_ENV || DEFAULT_BROWSER_TARGET;
    const COPY_SUFFIX = BROWSER_TARGET === DEFAULT_BROWSER_TARGET ? '' : `_${BROWSER_TARGET}`;

    Encore.reset();
    Encore
        // directory where compiled assets will be stored
        .setOutputPath(`static/build${COPY_SUFFIX}/`)
        // public path used by the web server to access the output path
        .setPublicPath(`/build${COPY_SUFFIX}/`)
        // only needed for CDN's or sub-directory deploy
        .setManifestKeyPrefix(`build${COPY_SUFFIX}/`)

        .copyFiles(
            BROWSER_TARGET === DEFAULT_BROWSER_TARGET
                ? [
                      {
                          from: './assets/images',
                          to: Encore.isProduction()
                              ? 'images/[path][name].[hash:8].[ext]'
                              : 'images/[path][name].[ext]',
                      },
                      {
                          from: './assets/svg',
                          to: Encore.isProduction() ? 'svg/[path][name].[hash:8].[ext]' : 'svg/[path][name].[ext]',
                      },
                      {
                          from: './assets/pdf',
                          to: 'pdf/[path][name].[ext]',
                      },
                  ]
                : []
        )

        /*
         * ENTRY CONFIG
         *
         * Add 1 entry for each "page" of your app
         * (including one that's included on every page - e.g. "app")
         *
         * Each entry will result in one JavaScript file (e.g. app.js)
         * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
         */
        .addEntry(
            'app',
            BROWSER_TARGET === 'modern' ? './assets/js/app.js' : ['./assets/js/polyfills.js', './assets/js/app.js']
        )

        // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
        .splitEntryChunks()

        // will require an extra script tag for runtime.js
        // but, you probably want this, unless you're building a single-page app
        .disableSingleRuntimeChunk()

        /*
         * FEATURE CONFIG
         *
         * Enable & configure other features below. For a full
         * list of features, see:
         * https://symfony.com/doc/current/frontend.html#adding-more-features
         */
        .cleanupOutputBeforeBuild()
        .enableBuildNotifications()
        .enableSourceMaps(!Encore.isProduction())
        // enables hashed filenames (e.g. app.abc123.css)
        .enableVersioning(Encore.isProduction())

        .configureBabel(() => {}, {
            // node_modules is not processed through Babel by default
            // but you can whitelist specific modules to process
            includeNodeModules: ['bootstrap', 'lazysizes', 'lite-youtube-embed', '@fortawesome'],
        })
        // enables @babel/preset-env polyfills
        .configureBabelPresetEnv((config) => {
            if (BROWSER_TARGET === 'modern') {
                config.modules = 'auto';
                config.targets = { esmodules: true };
            }

            config.browserslistEnv = BROWSER_TARGET;
            config.useBuiltIns = 'usage';
            config.corejs = 3;
        })

        // enables Sass/SCSS support
        .enableSassLoader();

    if (Encore.isProduction()) {
        Encore.addPlugin(
            new PurgecssPlugin({
                paths: glob.sync(
                    [
                        path.join(__dirname, 'content/**/*.md'),
                        path.join(__dirname, 'layouts/**/*.html'),
                        path.join(__dirname, 'assets/js/*.js'),
                        path.join(__dirname, 'node_modules/bootstrap/js/src/**/*.js'),
                        path.join(__dirname, 'node_modules/lazysizes/lazysizes.js'),
                        path.join(__dirname, 'node_modules/lite-youtube-embed/src/lite-yt-embed.js'),
                    ],
                    { nodir: true }
                ),
                safelist: {
                    standard: [/^weight-(\d+)$/],
                },
            })
        );
    }

    Encore.addPlugin(
        new FileManagerPlugin({
            events: {
                onEnd: {
                    copy: [
                        {
                            source: `./static/build${COPY_SUFFIX}/entrypoints.json`,
                            destination: `./data/entrypoints${COPY_SUFFIX}.json`,
                        },
                        {
                            source: `./static/build${COPY_SUFFIX}/manifest.json`,
                            destination: `./data/manifest${COPY_SUFFIX}.json`,
                        },
                    ],
                },
            },
        }),
        -11
    );

    let config = Encore.getWebpackConfig();
    config.name = BROWSERSLIST_ENV;

    if (BROWSER_TARGET === 'modern') {
        config.output.module = true;
        config.experiments = config.experiments || {};
        config.experiments.outputModule = true;
    } else {
        config.output.environment = config.output.environment || {};
        config.output.environment.arrowFunction = false;
        config.output.environment.const = false;
        config.output.environment.destructuring = false;
        config.output.environment.forOf = false;
    }

    return config;
};

// uncomment if you use TypeScript
//.enableTypeScriptLoader()

// uncomment to get integrity="..." attributes on your script & link tags
// requires WebpackEncoreBundle 1.4 or higher
//.enableIntegrityHashes(Encore.isProduction())

module.exports = Encore.isProduction() ? [makeConfig('modern'), makeConfig('legacy')] : [makeConfig('modern')];
<commit_msg>Added bugfixes options to webpack<commit_after>const Encore = require('@symfony/webpack-encore');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const PurgecssPlugin = require('purgecss-webpack-plugin');
const glob = require('glob-all');
const path = require('path');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

const makeConfig = (BROWSERSLIST_ENV) => {
    const DEFAULT_BROWSER_TARGET = 'modern';
    const BROWSER_TARGET = BROWSERSLIST_ENV || DEFAULT_BROWSER_TARGET;
    const COPY_SUFFIX = BROWSER_TARGET === DEFAULT_BROWSER_TARGET ? '' : `_${BROWSER_TARGET}`;

    Encore.reset();
    Encore
        // directory where compiled assets will be stored
        .setOutputPath(`static/build${COPY_SUFFIX}/`)
        // public path used by the web server to access the output path
        .setPublicPath(`/build${COPY_SUFFIX}/`)
        // only needed for CDN's or sub-directory deploy
        .setManifestKeyPrefix(`build${COPY_SUFFIX}/`)

        .copyFiles(
            BROWSER_TARGET === DEFAULT_BROWSER_TARGET
                ? [
                      {
                          from: './assets/images',
                          to: Encore.isProduction()
                              ? 'images/[path][name].[hash:8].[ext]'
                              : 'images/[path][name].[ext]',
                      },
                      {
                          from: './assets/svg',
                          to: Encore.isProduction() ? 'svg/[path][name].[hash:8].[ext]' : 'svg/[path][name].[ext]',
                      },
                      {
                          from: './assets/pdf',
                          to: 'pdf/[path][name].[ext]',
                      },
                  ]
                : []
        )

        /*
         * ENTRY CONFIG
         *
         * Add 1 entry for each "page" of your app
         * (including one that's included on every page - e.g. "app")
         *
         * Each entry will result in one JavaScript file (e.g. app.js)
         * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
         */
        .addEntry(
            'app',
            BROWSER_TARGET === 'modern' ? './assets/js/app.js' : ['./assets/js/polyfills.js', './assets/js/app.js']
        )

        // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
        .splitEntryChunks()

        // will require an extra script tag for runtime.js
        // but, you probably want this, unless you're building a single-page app
        .disableSingleRuntimeChunk()

        /*
         * FEATURE CONFIG
         *
         * Enable & configure other features below. For a full
         * list of features, see:
         * https://symfony.com/doc/current/frontend.html#adding-more-features
         */
        .cleanupOutputBeforeBuild()
        .enableBuildNotifications()
        .enableSourceMaps(!Encore.isProduction())
        // enables hashed filenames (e.g. app.abc123.css)
        .enableVersioning(Encore.isProduction())

        .configureBabel(() => {}, {
            // node_modules is not processed through Babel by default
            // but you can whitelist specific modules to process
            includeNodeModules: ['bootstrap', 'lazysizes', 'lite-youtube-embed', '@fortawesome'],
        })
        // enables @babel/preset-env polyfills
        .configureBabelPresetEnv((config) => {
            if (BROWSER_TARGET === 'modern') {
                config.modules = 'auto';
                config.bugfixes = true;
                config.targets = { esmodules: true };
            }

            config.browserslistEnv = BROWSER_TARGET;
            config.useBuiltIns = 'usage';
            config.corejs = 3;
        })

        // enables Sass/SCSS support
        .enableSassLoader();

    if (Encore.isProduction()) {
        Encore.addPlugin(
            new PurgecssPlugin({
                paths: glob.sync(
                    [
                        path.join(__dirname, 'content/**/*.md'),
                        path.join(__dirname, 'layouts/**/*.html'),
                        path.join(__dirname, 'assets/js/*.js'),
                        path.join(__dirname, 'node_modules/bootstrap/js/src/**/*.js'),
                        path.join(__dirname, 'node_modules/lazysizes/lazysizes.js'),
                        path.join(__dirname, 'node_modules/lite-youtube-embed/src/lite-yt-embed.js'),
                    ],
                    { nodir: true }
                ),
                safelist: {
                    standard: [/^weight-(\d+)$/],
                },
            })
        );
    }

    Encore.addPlugin(
        new FileManagerPlugin({
            events: {
                onEnd: {
                    copy: [
                        {
                            source: `./static/build${COPY_SUFFIX}/entrypoints.json`,
                            destination: `./data/entrypoints${COPY_SUFFIX}.json`,
                        },
                        {
                            source: `./static/build${COPY_SUFFIX}/manifest.json`,
                            destination: `./data/manifest${COPY_SUFFIX}.json`,
                        },
                    ],
                },
            },
        }),
        -11
    );

    let config = Encore.getWebpackConfig();
    config.name = BROWSERSLIST_ENV;

    if (BROWSER_TARGET === 'modern') {
        config.output.module = true;
        config.experiments = config.experiments || {};
        config.experiments.outputModule = true;
    } else {
        config.output.environment = config.output.environment || {};
        config.output.environment.arrowFunction = false;
        config.output.environment.const = false;
        config.output.environment.destructuring = false;
        config.output.environment.forOf = false;
    }

    return config;
};

// uncomment if you use TypeScript
//.enableTypeScriptLoader()

// uncomment to get integrity="..." attributes on your script & link tags
// requires WebpackEncoreBundle 1.4 or higher
//.enableIntegrityHashes(Encore.isProduction())

module.exports = Encore.isProduction() ? [makeConfig('modern'), makeConfig('legacy')] : [makeConfig('modern')];
<|endoftext|>


<commit_before>const BabiliPlugin = require('babili-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const path = require('path');
const { EnvironmentPlugin } = require('webpack');
const SubResourceIntegrityPlugin = require('webpack-subresource-integrity');

const HTML_MINIFIER_OPTIONS = {
  collapseBooleanAttributes: true,
  collapseInlineTagWhitespace: true,
  collapseWhitespace: true,
  includeAutoGeneratedTags: false,
  removeAttributeQuotes: true,
  removeComments: true,
  removeOptionalTags: true,
  removeScriptTypeAttributes: true,
  removeStyleLinkTypeAttributes: true,
  sortAttributes: true,
  sortClassName: true,
};

module.exports = (env = process.env.NODE_ENV) => {
  process.env.NODE_ENV = env;
  return {
    devServer: {
      historyApiFallback: true,
    },
    devtool: 'source-map',
    entry: {
      main: path.resolve(__dirname, 'src', 'main.js'),
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          loader: 'babel-loader',
        },
      ],
    },
    output: {
      chunkFilename: env === 'production' ? '[name].[chunkhash].js' : '[name].js?[chunkhash]',
      crossOriginLoading: 'anonymous',
      filename: env === 'production' ? '[name].[chunkhash].js' : '[name].js?[chunkhash]',
      path: path.resolve(__dirname, 'public'),
      publicPath: '/',
    },
    plugins: [
      new EnvironmentPlugin({
        NODE_ENV: env || 'development',
      }),
      new HtmlPlugin({
        minify: env === 'production' ? HTML_MINIFIER_OPTIONS : false,
        template: path.resolve(__dirname, 'src', 'templates', 'index.html.ejs'),
        title: 'MastodonKaigi',
      }),
      ...(env === 'production' ? [
        new SubResourceIntegrityPlugin({
          hashFuncNames: ['sha384'],
        }),
        new CopyPlugin(['_redirects', '_headers', 'favicon.ico'].map(filename => ({
          from: path.resolve(__dirname, 'src', 'templates', filename),
        }))),
        new BabiliPlugin(),
      ] : []),
    ],
  };
};
<commit_msg>ModuleConcatenationPlugin (#67)<commit_after>const BabiliPlugin = require('babili-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const path = require('path');
const {
  EnvironmentPlugin,
  optimize: { ModuleConcatenationPlugin },
} = require('webpack');
const SubResourceIntegrityPlugin = require('webpack-subresource-integrity');

const HTML_MINIFIER_OPTIONS = {
  collapseBooleanAttributes: true,
  collapseInlineTagWhitespace: true,
  collapseWhitespace: true,
  includeAutoGeneratedTags: false,
  removeAttributeQuotes: true,
  removeComments: true,
  removeOptionalTags: true,
  removeScriptTypeAttributes: true,
  removeStyleLinkTypeAttributes: true,
  sortAttributes: true,
  sortClassName: true,
};

module.exports = (env = process.env.NODE_ENV) => {
  process.env.NODE_ENV = env;
  return {
    devServer: {
      historyApiFallback: true,
    },
    devtool: 'source-map',
    entry: {
      main: path.resolve(__dirname, 'src', 'main.js'),
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          loader: 'babel-loader',
        },
      ],
    },
    output: {
      chunkFilename: env === 'production' ? '[name].[chunkhash].js' : '[name].js?[chunkhash]',
      crossOriginLoading: 'anonymous',
      filename: env === 'production' ? '[name].[chunkhash].js' : '[name].js?[chunkhash]',
      path: path.resolve(__dirname, 'public'),
      publicPath: '/',
    },
    plugins: [
      new EnvironmentPlugin({
        NODE_ENV: env || 'development',
      }),
      new ModuleConcatenationPlugin(),
      new HtmlPlugin({
        minify: env === 'production' ? HTML_MINIFIER_OPTIONS : false,
        template: path.resolve(__dirname, 'src', 'templates', 'index.html.ejs'),
        title: 'MastodonKaigi',
      }),
      ...(env === 'production' ? [
        new SubResourceIntegrityPlugin({
          hashFuncNames: ['sha384'],
        }),
        new CopyPlugin(['_redirects', '_headers', 'favicon.ico'].map(filename => ({
          from: path.resolve(__dirname, 'src', 'templates', filename),
        }))),
        new BabiliPlugin(),
      ] : []),
    ],
  };
};
<|endoftext|>


<commit_before>var Webpack = require('webpack');
var path = require('path');

module.exports = {
	entry: [
		'webpack/hot/dev-server',
		'webpack-dev-server/client?http://localhost:8080',
		path.resolve(__dirname, 'app', 'main.js')
	],

	output: {
		path: path.resolve(__dirname, 'app', 'build'),
		filename: 'bundle.js',
		publicPath:'/'
	},

	devServer: {
		contentBase: path.resolve(__dirname, 'app')
	},

	module: {
		loaders: [
			{test: /\.scss$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']},
			{test: /\.html$/, loader: 'raw'}
		]
	},

	sassLoader: {
		includePaths: [path.resolve(__dirname, 'app', 'gfx')]
	},

	plugins: [
		new Webpack.HotModuleReplacementPlugin(),
		new Webpack.NoErrorsPlugin()
	],

	devtool: 'source-map'

};<commit_msg>fixed hot reload bug<commit_after>var Webpack = require('webpack');
var path = require('path');

module.exports = {
	entry: [
		//'webpack/hot/dev-server',
		//'webpack-dev-server/client?http://localhost:8080',
		path.resolve(__dirname, 'app', 'main.js')
	],

	output: {
		path: path.resolve(__dirname, 'app', 'build'),
		filename: 'bundle.js',
		publicPath:'/'
	},

	devServer: {
		contentBase: path.resolve(__dirname, 'app')
	},

	module: {
		loaders: [
			{test: /\.scss$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']},
			{test: /\.html$/, loader: 'raw'}
		]
	},

	sassLoader: {
		includePaths: [path.resolve(__dirname, 'app', 'gfx')]
	},

	plugins: [
		//new Webpack.HotModuleReplacementPlugin(),
		new Webpack.NoErrorsPlugin()
	],

	devtool: 'source-map'

};<|endoftext|>


<commit_before>'use strict';

var webpack           = require('webpack'),
    CleanPlugin       = require('clean-webpack-plugin'),
    ExtractTextPlugin = require('extract-text-webpack-plugin'),
    HtmlPlugin        = require('html-webpack-plugin'),
    ESManglePlugin    = require('esmangle-webpack-plugin'),
    BrowserSyncPlugin = require('browser-sync-webpack-plugin'),
    OmitTildePlugin   = require('omit-tilde-webpack-plugin');

function config() {

    // define Webpack configuration object to be exported
    return {
        context: __dirname,
        cache  : true,
        devtool: 'source-map',
        entry  : {
            vendor: Object.keys(require('./bower.json').dependencies),
            index : [
                './app/index.js',
                './app/index.scss'
            ]
        },
        output : {
            path                                 : __dirname + '/app-build',
            filename                             : 'assets/[name].[chunkhash].js',
            devtoolModuleFilenameTemplate        : '[absolute-resource-path]',
            devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
        },
        resolve: {
            alias: {
                npm: __dirname + '/node_modules'
            },
            root : __dirname + '/bower_components'
        },
        module : {
            preloaders: [
                {
                    test   : /\.js?$/,
                    exclude: './node_modules',
                    loader : 'jshint'
                }
            ],
            loaders   : [
                {
                    test  : /\.css$/,
                    loader: ExtractTextPlugin.extract(
                        'style',
                        'css?minimize&sourceMap!resolve-url?sourceMap'
                    )
                }, {
                    test  : /\.scss$/,
                    loader: ExtractTextPlugin.extract(
                        'style',
                        'css?minimize&sourceMap!resolve-url?sourceMap!sass'
                    )
                }, {
                    test   : /\.(jpe?g|png|gif|svg)$/i,
                    loaders: [
                        'file?hash=sha512&digest=hex&name=/assets/[hash].[ext]',
                        'image-webpack?optimizationLevel=7&interlaced=false'
                    ]
                }, {
                    test  : /\.woff2?$/,
                    loader: 'url?limit=10000&mimetype=application/font-woff&name=/assets/[hash].[ext]'
                }, {
                    test  : /\.(eot|ttf)$/,
                    loader: 'file?name=/assets/[hash].[ext]'
                }, {
                    test   : /\.js$/,
                    include: /bower_components/,
                    loader : 'ng-annotate?sourceMap'
                }, {
                    test   : /\.js$/,
                    exclude: /bower_components/,
                    loaders: [
                        'ng-annotate?sourceMap',
                        'nginject?sourceMap',
                        'babel?stage=4&sourceMap&ignore=buffer' // https://github.com/feross/buffer/issues/79
                    ]
                }, {
                    test  : /\.html?$/,
                    loader: 'html'
                }, {
                    test  : /\.json$/,
                    loader: 'json'
                }
            ]
        },
        plugins: [
            new CleanPlugin(['app-build']),
            new OmitTildePlugin({
                include  : ['package.json', 'bower.json'],
                deprecate: true
            }),
            new webpack.ResolverPlugin([
                new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('bower.json', ['main'])
            ]),
            new webpack.ProvidePlugin({
                $     : 'jquery',
                jQuery: 'jquery'
            }),
            new ExtractTextPlugin('assets/[name].[contenthash].css', {
                allChunks: true
            }),
            new webpack.optimize.CommonsChunkPlugin({
                name     : 'vendor',
                minChunks: Infinity
            }),
            new HtmlPlugin({
                title   : 'Custom template',
                template: __dirname + '/app/index.html',
                inject  : 'body'
            }),
            new webpack.optimize.DedupePlugin(),
            new ESManglePlugin(),
            new BrowserSyncPlugin({
                host  : 'localhost',
                port  : 55555,
                server: {
                    baseDir: 'app-build',
                    routes : {'/': ''}
                }
            })
        ]
    };
}

module.exports = config();<commit_msg>minor fixes<commit_after>'use strict';

var webpack           = require('webpack'),
    CleanPlugin       = require('clean-webpack-plugin'),
    ExtractTextPlugin = require('extract-text-webpack-plugin'),
    HtmlPlugin        = require('html-webpack-plugin'),
    ESManglePlugin    = require('esmangle-webpack-plugin'),
    BrowserSyncPlugin = require('browser-sync-webpack-plugin'),
    OmitTildePlugin   = require('omit-tilde-webpack-plugin');

function config() {

    // define Webpack configuration object to be exported
    return {
        name   : require('./package.json').name,
        context: __dirname,
        cache  : true,
        devtool: 'source-map',
        entry  : {
            vendor: Object.keys(require('./bower.json').dependencies),
            index : [
                './app/index.js',
                './app/index.scss'
            ]
        },
        output : {
            path                                 : __dirname + '/app-build',
            filename                             : 'assets/[name].[chunkhash].js',
            devtoolModuleFilenameTemplate        : '[absolute-resource-path]',
            devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
        },
        resolve: {
            alias: {
                npm: __dirname + '/node_modules'
            },
            root : __dirname + '/bower_components'
        },
        module : {
            preloaders: [
                {
                    test   : /\.js?$/,
                    exclude: './node_modules',
                    loader : 'jshint'
                }
            ],
            loaders   : [
                {
                    test  : /\.css$/,
                    loader: ExtractTextPlugin.extract(
                        'style',
                        'css?minimize&sourceMap!resolve-url?sourceMap'
                    )
                }, {
                    test  : /\.scss$/,
                    loader: ExtractTextPlugin.extract(
                        'style',
                        'css?minimize&sourceMap!resolve-url?sourceMap!sass?sourceMap'
                    )
                }, {
                    test   : /\.(jpe?g|png|gif|svg)$/i,
                    loaders: [
                        'file?hash=sha512&digest=hex&name=/assets/[hash].[ext]',
                        'image-webpack?optimizationLevel=7&interlaced=false'
                    ]
                }, {
                    test  : /\.woff2?$/,
                    loader: 'url?limit=10000&mimetype=application/font-woff&name=/assets/[hash].[ext]'
                }, {
                    test  : /\.(eot|ttf)$/,
                    loader: 'file?name=/assets/[hash].[ext]'
                }, {
                    test   : /\.js$/,
                    include: /bower_components/,
                    loader : 'ng-annotate?sourceMap'
                }, {
                    test   : /\.js$/,
                    exclude: /bower_components/,
                    loaders: [
                        'ng-annotate?sourceMap',
                        'nginject?sourceMap',
                        'babel?stage=4&sourceMap&ignore=buffer' // https://github.com/feross/buffer/issues/79
                    ]
                }, {
                    test  : /\.html?$/,
                    loader: 'html'
                }, {
                    test  : /\.json$/,
                    loader: 'json'
                }
            ]
        },
        plugins: [
            new CleanPlugin(['app-build']),
            new OmitTildePlugin({
                include  : ['package.json', 'bower.json'],
                deprecate: true
            }),
            new webpack.ResolverPlugin([
                new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('bower.json', ['main'])
            ]),
            new webpack.ProvidePlugin({
                $     : 'jquery',
                jQuery: 'jquery'
            }),
            new ExtractTextPlugin('assets/[name].[contenthash].css', {
                allChunks: true
            }),
            new webpack.optimize.CommonsChunkPlugin({
                name     : 'vendor',
                minChunks: Infinity
            }),
            new HtmlPlugin({
                title   : 'Custom template',
                template: __dirname + '/app/index.html',
                inject  : 'body'
            }),
            new webpack.optimize.DedupePlugin(),
            new ESManglePlugin(),
            new BrowserSyncPlugin({
                host  : 'localhost',
                port  : 55555,
                server: {
                    baseDir: 'app-build',
                    routes : {'/': ''}
                }
            })
        ]
    };
}

module.exports = config();<|endoftext|>