<commit_before>import Field from '../Field';
import React from 'react';
import { Button, FormField, FormInput, FormNote } from 'elemental';

module.exports = Field.create({

	displayName: 'FileField',
	statics: {
		type: 'File',
	},

	shouldCollapse () {
		return this.props.collapse && !this.hasExisting();
	},

	fileFieldNode () {
		return this.refs.fileField;
	},

	changeFile () {
		this.fileFieldNode().click();
	},

	getFileSource () {
		if (this.hasLocal()) {
			return this.state.localSource;
		} else if (this.hasExisting()) {
			return this.props.value.url;
		} else {
			return null;
		}
	},

	getFileURL () {
		if (!this.hasLocal() && this.hasExisting()) {
			return this.props.value.url;
		}
	},

	undoRemove () {
		this.fileFieldNode().value = '';
		this.setState({
			removeExisting: false,
			localSource: null,
			origin: false,
			action: null,
		});
	},

	fileChanged (event) { // eslint-disable-line no-unused-vars
		this.setState({
			origin: 'local',
		});
	},

	removeFile (e) {
		var state = {
			localSource: null,
			origin: false,
		};

		if (this.hasLocal()) {
			this.fileFieldNode().value = '';
		} else if (this.hasExisting()) {
			state.removeExisting = true;

			if (this.props.autoCleanup) {
				if (e.altKey) {
					state.action = 'reset';
				} else {
					state.action = 'delete';
				}
			} else {
				if (e.altKey) {
					state.action = 'delete';
				} else {
					state.action = 'reset';
				}
			}
		}

		this.setState(state);
	},

	hasLocal () {
		return this.state.origin === 'local';
	},

	hasExisting () {
		return this.props.value && !!this.props.value.filename;
	},

	hasFile () {
		return this.hasExisting() || this.hasLocal();
	},

	getFilename () {
		if (this.hasLocal()) {
			return this.fileFieldNode().value.split('\\').pop();
		} else {
			return this.props.value.filename;
		}
	},

	renderFileDetails (add) {
		var details = null;
		var href = this.getFileURL();

		if (this.hasFile() && !this.state.removeExisting) {
			details = (

					<FormInput noedit>{href ? (
						{this.getFilename()}
					) : this.getFilename()}</FormInput>

			);
		}

		return (

				{details}
				{add}

		);
	},

	renderAlert () {
		if (this.hasLocal()) {
			return (

					<FormInput noedit>File selected - save to upload</FormInput>

			);
		} else if (this.state.origin === 'cloudinary') {
			return (

					<FormInput noedit>File selected from Cloudinary</FormInput>

			);
		} else if (this.state.removeExisting) {
			return (

					<FormInput noedit>File {this.props.autoCleanup ? 'deleted' : 'removed'} - save to confirm</FormInput>

			);
		} else {
			return null;
		}
	},

	renderClearButton () {
		if (this.state.removeExisting) {
			return (
				<Button type="link" onClick={this.undoRemove}>
					Undo Remove
				</Button>
			);
		} else {
			var clearText;
			if (this.hasLocal()) {
				clearText = 'Cancel Upload';
			} else {
				clearText = (this.props.autoCleanup ? 'Delete File' : 'Remove File');
			}
			return (
				<Button type="link-cancel" onClick={this.removeFile}>
					{clearText}
				</Button>
			);
		}
	},

	renderFileField () {
		if (!this.shouldRenderField()) return null;

		return <input ref="fileField" type="file" name={this.props.paths.upload} className="field-upload" onChange={this.fileChanged} tabIndex="-1" />;
	},

	renderFileAction () {
		if (!this.shouldRenderField()) return null;

		return <input type="hidden" name={this.props.paths.action} className="field-action" value={this.state.action} />;
	},

	renderFileToolbar () {
		return (

					<Button onClick={this.changeFile}>
						{this.hasFile() ? 'Change' : 'Upload'} File
					</Button>
					{this.hasFile() && this.renderClearButton()}

		);
	},

	renderNote () {
		if (!this.props.note) return null;

		return <FormNote note={this.props.note} />;
	},

	renderUI () {
		var container = [];
		var body = [];
		var hasFile = this.hasFile();

		if (this.shouldRenderField()) {
			if (hasFile) {
				container.push(this.renderFileDetails(this.renderAlert()));
			}
			body.push(this.renderFileToolbar());
		} else {
			if (hasFile) {
				container.push(this.renderFileDetails());
			} else {
				container.push(<FormInput noedit>no file</FormInput>);
			}
		}

		return (
			<FormField label={this.props.label} className="field-type-localfile" htmlFor={this.props.path}>

				{this.renderFileField()}
				{this.renderFileAction()}

{container}

				{body}
				{this.renderNote()}

			</FormField>
		);
	},

});
<commit_msg>Migrating @jossmac's changes from LocalFile to File<commit_after>import Field from '../Field';
import React, { PropTypes } from 'react';
import { Button, FormField, FormInput, FormNote } from 'elemental';
import FileChangeMessage from '../../components/FileChangeMessage';
import HiddenFileInput from '../../components/HiddenFileInput';

const buildInitialState = () => ({
	action: null,
	removeExisting: false,
	userSelectedFile: null,
});

module.exports = Field.create({
	propTypes: {
		autoCleanup: PropTypes.bool,
		collapse: PropTypes.bool,
		label: PropTypes.string,
		note: PropTypes.string,
		path: PropTypes.string.isRequired,
		paths: PropTypes.shape({
			action: PropTypes.string.isRequired,
			upload: PropTypes.string.isRequired,
		}).isRequired,
		value: PropTypes.shape({
			filename: PropTypes.string,
			// TODO: these are present but not used in the UI,
			//       should we start using them?
			// filetype: PropTypes.string,
			// originalname: PropTypes.string,
			// path: PropTypes.string,
			// size: PropTypes.number,
		}),
	},
	getInitialState () {
		return buildInitialState();
	},
	shouldCollapse () {
		return this.props.collapse && !this.hasExisting();
	},

	// ==============================
	// HELPERS
	// ==============================

	hasFile () {
		return this.hasExisting() || !!this.state.userSelectedFile;
	},
	hasExisting () {
		return this.props.value && !!this.props.value.filename;
	},
	getFilename () {
		return this.state.userSelectedFile
			? this.state.userSelectedFile.name
			: this.props.value.filename;
	},

	// ==============================
	// METHODS
	// ==============================

	triggerFileBrowser () {
		this.refs.fileInput.clickDomNode();
	},
	handleFileChange (event) {
		const userSelectedFile = event.target.files[0];

		this.setState({
			userSelectedFile: userSelectedFile,
		});
	},
	handleRemove (e) {
		var state = {};

		if (this.state.userSelectedFile) {
			state.userSelectedFile = null;
		} else if (this.hasExisting()) {
			state.removeExisting = true;

			if (this.props.autoCleanup) {
				if (e.altKey) {
					state.action = 'reset';
				} else {
					state.action = 'delete';
				}
			} else {
				if (e.altKey) {
					state.action = 'delete';
				} else {
					state.action = 'reset';
				}
			}
		}

		this.setState(state);
	},
	undoRemove () {
		this.setState(buildInitialState());
	},

	// ==============================
	// RENDERERS
	// ==============================

	renderFileNameAndOptionalMessage (showChangeMessage = false) {
		return (

				{(this.hasFile() && !this.state.removeExisting) ? (
					<FileChangeMessage>
						{this.getFilename()}
					</FileChangeMessage>
				) : null}
				{showChangeMessage && this.renderChangeMessage()}

		);
	},
	renderChangeMessage () {
		if (this.state.userSelectedFile) {
			return (
				<FileChangeMessage type="success">
					File selected - save to upload
				</FileChangeMessage>
			);
		} else if (this.state.removeExisting) {
			return (
				<FileChangeMessage type="danger">
					File {this.props.autoCleanup ? 'deleted' : 'removed'} - save to confirm
				</FileChangeMessage>
			);
		} else {
			return null;
		}
	},
	renderClearButton () {
		if (this.state.removeExisting) {
			return (
				<Button type="link" onClick={this.undoRemove}>
					Undo Remove
				</Button>
			);
		} else {
			var clearText;
			if (this.state.userSelectedFile) {
				clearText = 'Cancel Upload';
			} else {
				clearText = (this.props.autoCleanup ? 'Delete File' : 'Remove File');
			}
			return (
				<Button type="link-cancel" onClick={this.handleRemove}>
					{clearText}
				</Button>
			);
		}
	},
	renderUI () {
		const buttons = (

				<Button onClick={this.triggerFileBrowser}>
					{this.hasFile() ? 'Change' : 'Upload'} File
				</Button>
				{this.hasFile() && this.renderClearButton()}

		);

		return (

				<FormField label={this.props.label} htmlFor={this.props.path}>
					{this.shouldRenderField() ? (

							{this.hasFile() && this.renderFileNameAndOptionalMessage(true)}
							{buttons}
							<HiddenFileInput
								name={this.props.paths.upload}
								onChange={this.handleFileChange}
								ref="fileInput"
							/>
							<input
								name={this.props.paths.action}
								type="hidden"
								value={this.state.action}
							/>

					) : (

							{this.hasFile()
								? this.renderFileNameAndOptionalMessage()
								: <FormInput noedit>no file</FormInput>}

					)}
					{!!this.props.note && <FormNote note={this.props.note} />}
				</FormField>

		);
	},

});
<|endoftext|>


<commit_before>'use strict'

var webpack = require('webpack')
var path = require('path')

var NODE_ENV = process.env.NODE_ENV || 'development'

module.exports = {
  entry: {
    app: './docs/app.js'
  },
  output: {
    path: path.join(__dirname, './dist'),
    filename: 'build.js'
  },
  watch: NODE_ENV === 'development',
  watchOptions: {
    aggregateTimeout: 100
  },
  devtool: NODE_ENV === 'development' ? 'cheap-inline-module-source-map' : null,
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.vue'],
    alias: {
      vue: 'vue/dist/vue.js'
    }
  }
}

if (NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webapck.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ])
}<commit_msg>modified entry config<commit_after>'use strict'

var webpack = require('webpack')
var path = require('path')

var NODE_ENV = process.env.NODE_ENV || 'development'

module.exports = {
  entry: {
    app: './examples/app.js'
  },
  output: {
    path: path.join(__dirname, './dist'),
    filename: 'build.js'
  },
  watch: NODE_ENV === 'development',
  watchOptions: {
    aggregateTimeout: 100
  },
  devtool: NODE_ENV === 'development' ? 'cheap-inline-module-source-map' : null,
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.vue'],
    alias: {
      vue: 'vue/dist/vue.js'
    }
  }
}

if (NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webapck.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ])
}<|endoftext|>


<commit_before>var tinymce = require('tinymce'),
	React = require('react'),
	Field = require('../Field'),
	_ = require('underscore');

var lastId = 0;

function getId() {
	return 'keystone-html-' + lastId++;
}

module.exports = Field.create({

	getInitialState: function() {
		return {
			id: getId()
		};
	},

	componentDidMount: function() {
		if (!this.props.wysiwyg) return;

		var self = this;
		var opts = this.getOptions();

		opts.setup = function (editor) {
			self.editor = editor;
			editor.on('change', self.valueChanged);
		};

		this._currentValue = this.props.value;
		tinymce.init(opts);
	},

	componentWillReceiveProps: function(nextProps) {
		if (this.editor && this._currentValue !== nextProps.value) {
			this.editor.setContent(nextProps.value);
		}
	},

	valueChanged: function () {
		var content;
		if (this.editor) {
			content = this.editor.getContent();
		} else if (this.refs.editor) {
			content = this.refs.editor.getDOMNode().value;
		} else {
			return;
		}

		this._currentValue = content;
		this.props.onChange({
			path: this.props.path,
			value: content
		});
	},

	getOptions: function() {
  		var plugins = [ 'code', 'link' ],
  			toolbar = Keystone.wysiwyg.options.overrideToolbar ? '' : 'bold italic | alignleft aligncenter alignright | bullist numlist | outdent indent | link';

		if (Keystone.wysiwyg.options.enableImages) {
			plugins.push('image');
			toolbar += ' | image';
		}

		if (Keystone.wysiwyg.options.enableCloudinaryUploads) {
			plugins.push('uploadimage');
			toolbar += Keystone.wysiwyg.options.enableImages ? ' uploadimage' : ' | uploadimage';
		}

		if (Keystone.wysiwyg.options.additionalButtons) {
			var additionalButtons = Keystone.wysiwyg.options.additionalButtons.split(',');
			for (var i = 0; i < additionalButtons.length; i++) {
				toolbar += (' | ' + additionalButtons[i]);
			}
		}
		if (Keystone.wysiwyg.options.additionalPlugins) {
			var additionalPlugins = Keystone.wysiwyg.options.additionalPlugins.split(',');
			for (var i = 0; i < additionalPlugins.length; i++) {
				plugins.push(additionalPlugins[i]);
			}
		}
		if (Keystone.wysiwyg.options.importcss) {
			plugins.push('importcss');
			var importcssOptions = {
				content_css: Keystone.wysiwyg.options.importcss,
				importcss_append: true,
				importcss_merge_classes: true
			};
			$.extend(Keystone.wysiwyg.options.additionalOptions,importcssOptions);
		}
		if (!Keystone.wysiwyg.options.overrideToolbar) {
			toolbar += ' | code';
		}

		var opts = {
			selector: '#' + this.state.id,
			toolbar:  toolbar,
			plugins:  plugins,
			menubar:  Keystone.wysiwyg.options.menubar || false,
			skin:     Keystone.wysiwyg.options.skin || 'keystone'
		};

		if (this.props.noedit) {
			_.extend(opts, {
				mode: 'textareas',
				readonly: true,
				menubar: false,
				toolbar: 'code',
				statusbar: false
			});
		} else {
			opts.uploadimage_form_url = '/keystone/api/cloudinary/upload';
		}

		if (Keystone.wysiwyg.options.additionalOptions){
			_.extend(opts, Keystone.wysiwyg.options.additionalOptions);
		}

		return opts;
	},

	getFieldClassName: function() {
		return this.props.wysiwyg ? 'wysiwyg' : 'code';
	},

	renderEditor: function(readOnly) {
		var style = {
			height: this.props.height
		};
		return (
			<textarea ref='editor' style={style} onChange={this.valueChanged} id={this.state.id} className={this.getFieldClassName()} name={this.props.path} readOnly={readOnly}>
				{this.props.value}
			</textarea>
		);
	},

	renderField: function() {
		return this.renderEditor();
	},

	renderValue: function() {
		return this.renderEditor(true);
	}

});
<commit_msg>Fixing a React warning about textareas<commit_after>var tinymce = require('tinymce'),
	React = require('react'),
	Field = require('../Field'),
	_ = require('underscore');

var lastId = 0;

function getId() {
	return 'keystone-html-' + lastId++;
}

module.exports = Field.create({

	getInitialState: function() {
		return {
			id: getId()
		};
	},

	componentDidMount: function() {
		if (!this.props.wysiwyg) return;

		var self = this;
		var opts = this.getOptions();

		opts.setup = function (editor) {
			self.editor = editor;
			editor.on('change', self.valueChanged);
		};

		this._currentValue = this.props.value;
		tinymce.init(opts);
	},

	componentWillReceiveProps: function(nextProps) {
		if (this.editor && this._currentValue !== nextProps.value) {
			this.editor.setContent(nextProps.value);
		}
	},

	valueChanged: function () {
		var content;
		if (this.editor) {
			content = this.editor.getContent();
		} else if (this.refs.editor) {
			content = this.refs.editor.getDOMNode().value;
		} else {
			return;
		}

		this._currentValue = content;
		this.props.onChange({
			path: this.props.path,
			value: content
		});
	},

	getOptions: function() {
  		var plugins = [ 'code', 'link' ],
  			toolbar = Keystone.wysiwyg.options.overrideToolbar ? '' : 'bold italic | alignleft aligncenter alignright | bullist numlist | outdent indent | link';

		if (Keystone.wysiwyg.options.enableImages) {
			plugins.push('image');
			toolbar += ' | image';
		}

		if (Keystone.wysiwyg.options.enableCloudinaryUploads) {
			plugins.push('uploadimage');
			toolbar += Keystone.wysiwyg.options.enableImages ? ' uploadimage' : ' | uploadimage';
		}

		if (Keystone.wysiwyg.options.additionalButtons) {
			var additionalButtons = Keystone.wysiwyg.options.additionalButtons.split(',');
			for (var i = 0; i < additionalButtons.length; i++) {
				toolbar += (' | ' + additionalButtons[i]);
			}
		}
		if (Keystone.wysiwyg.options.additionalPlugins) {
			var additionalPlugins = Keystone.wysiwyg.options.additionalPlugins.split(',');
			for (var i = 0; i < additionalPlugins.length; i++) {
				plugins.push(additionalPlugins[i]);
			}
		}
		if (Keystone.wysiwyg.options.importcss) {
			plugins.push('importcss');
			var importcssOptions = {
				content_css: Keystone.wysiwyg.options.importcss,
				importcss_append: true,
				importcss_merge_classes: true
			};
			$.extend(Keystone.wysiwyg.options.additionalOptions,importcssOptions);
		}
		if (!Keystone.wysiwyg.options.overrideToolbar) {
			toolbar += ' | code';
		}

		var opts = {
			selector: '#' + this.state.id,
			toolbar:  toolbar,
			plugins:  plugins,
			menubar:  Keystone.wysiwyg.options.menubar || false,
			skin:     Keystone.wysiwyg.options.skin || 'keystone'
		};

		if (this.props.noedit) {
			_.extend(opts, {
				mode: 'textareas',
				readonly: true,
				menubar: false,
				toolbar: 'code',
				statusbar: false
			});
		} else {
			opts.uploadimage_form_url = '/keystone/api/cloudinary/upload';
		}

		if (Keystone.wysiwyg.options.additionalOptions){
			_.extend(opts, Keystone.wysiwyg.options.additionalOptions);
		}

		return opts;
	},

	getFieldClassName: function() {
		return this.props.wysiwyg ? 'wysiwyg' : 'code';
	},

	renderEditor: function(readOnly) {
		var style = {
			height: this.props.height
		};
		return (
			<textarea ref='editor' style={style} onChange={this.valueChanged} id={this.state.id} className={this.getFieldClassName()} name={this.props.path} readOnly={readOnly} value={this.props.value}></textarea>
		);
	},

	renderField: function() {
		return this.renderEditor();
	},

	renderValue: function() {
		return this.renderEditor(true);
	}

});
<|endoftext|>


<commit_before>const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const uglifySaveLicense = require('uglify-save-license');

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

const common = {
  devtool: isProduction
    ? false
    : 'inline-source-map',
  node: {
    __filename: true,
    __dirname: true
  },
  resolve: { extensions: ['.ts', '.tsx', '.js'] },
  watchOptions: {
    ignored: /node_modules|lib/
  }
};

function tsModule(targets) {
  return {
    rules: [{
      test: /\.tsx?$/,
      use: [
        {
          loader: 'babel-loader',
          options: {
            env: {
              development: {
                plugins: [[
                  'babel-plugin-espower',
                  { 'embedAst': true }
                ]]
              },
              production: {
                presets: ['babili']
              }
            },
            presets: [['env', { targets }]]
          }
        },
        {
          loader: 'ts-loader',
          options: { compilerOptions: { sourceMap: !isProduction } }
        }
      ]
    }]
  };
}

module.exports = [
  Object.assign({},
    common,
    {
      entry: {
        index: ['babel-polyfill', './src/public/js/index.ts']
      },
      module: tsModule({ browsers: ['last 2 versions'] }),
      output: {
        filename: 'lib/public/js/[name].js'
      },
      plugins: [
        new CopyWebpackPlugin(
          [{ from: 'src/public/', to: 'lib/public/' }],
          {
            ignore: [
              'test/',
              '*.ts',
              '*.tsx'
            ]
          })
      ]
        .concat(isProduction
          ? [
            new webpack.optimize.UglifyJsPlugin({
              output: { comments: uglifySaveLicense }
            })
          ]
          : []
        ),
      target: 'web'
    }
  ),
  Object.assign({},
    common,
    {
      entry: {
        index: ['babel-polyfill', './src/index.ts'],
        'test/test': ['babel-polyfill', './src/test/test.ts']
      },
      externals: /^(?!\.)/,
      module: tsModule({ node: 6 }),
      output: {
        filename: 'lib/[name].js',
        libraryTarget: 'commonjs2'
      },
      target: 'node'
    }
  )
];
<commit_msg>refactor: refactor<commit_after>const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const uglifySaveLicense = require('uglify-save-license');

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

const common = {
  devtool: isProduction ? false : 'inline-source-map',
  node: { __dirname: true, __filename: true },
  resolve: { extensions: ['.ts', '.tsx', '.js'] },
  watchOptions: { ignored: /node_modules|lib/ }
};

function tsModule(targets) {
  return {
    rules: [{
      test: /\.tsx?$/,
      use: [
        {
          loader: 'babel-loader',
          options: {
            env: {
              development: {
                plugins: [['babel-plugin-espower', { 'embedAst': true }]]
              },
              production: {
                presets: ['babili']
              }
            },
            presets: [['env', { targets }]]
          }
        },
        {
          loader: 'ts-loader',
          options: { compilerOptions: { sourceMap: !isProduction } }
        }
      ]
    }]
  };
}

module.exports = [
  Object.assign({},
    common,
    {
      entry: {
        index: ['babel-polyfill', './src/public/js/index.ts']
      },
      module: tsModule({ uglify: true }),
      output: { filename: 'lib/public/js/[name].js' },
      plugins: [
        ...[
          new CopyWebpackPlugin(
            [{ from: 'src/public/', to: 'lib/public/' }],
            {
              ignore: [
                'test/',
                '*.ts',
                '*.tsx'
              ]
            })
        ],
        ...(
          !isProduction ? [] : [
            new webpack.optimize.UglifyJsPlugin({
              output: { comments: uglifySaveLicense }
            })
          ]
        )
      ],
      target: 'web'
    }
  ),
  Object.assign({},
    common,
    {
      entry: {
        index: ['babel-polyfill', './src/index.ts'],
        'test/test': ['babel-polyfill', './src/test/test.ts']
      },
      externals: /^(?!\.)/,
      module: tsModule({ node: 6 }),
      output: { filename: 'lib/[name].js', libraryTarget: 'commonjs2' },
      target: 'node'
    }
  )
];
<|endoftext|>


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

module.exports = {
  devtool: 'eval',
  entry: [
    'webpack-dev-server/client?http://0.0.0.0:3000',
    'webpack/hot/only-dev-server',
    './scripts/index'
  ],
  output: {
    path: __dirname,
    filename: 'bundle.js',
    publicPath: '/scripts/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  resolve: {
    extensions: ['', '.js', '.json']
  },
  module: {
    loaders: [
      {test: /\.json$/, loader: 'json-loader'},
      { test: /\.js$/, exclude: /node_modules/, loaders: ['react-hot', '6to5-loader'] }
    ]
  }
};
<commit_msg>point entry to app.js<commit_after>var webpack = require('webpack');

module.exports = {
  devtool: 'eval',
  entry: [
    'webpack-dev-server/client?http://0.0.0.0:3000',
    'webpack/hot/only-dev-server',
    './scripts/app'
  ],
  output: {
    path: __dirname,
    filename: 'bundle.js',
    publicPath: '/scripts/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  resolve: {
    extensions: ['', '.js', '.json']
  },
  module: {
    loaders: [
      {test: /\.json$/, loader: 'json-loader'},
      { test: /\.js$/, exclude: /node_modules/, loaders: ['react-hot', '6to5-loader'] }
    ]
  }
};
<|endoftext|>


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

var plugins = [];
var output = 'build';

var isProduction = process.argv.indexOf('-p') >= 0 ? true : false;

if (isProduction) {
  output = 'dist';

  plugins.push(new webpack.optimize.UglifyJsPlugin({minimize: true}));
}

module.exports = {
  entry: [
    './src/index.tsx',
    './index.html'
  ],
  output: {
    path: path.join(__dirname, output),
    filename: 'app.js'
  },
  plugins: plugins,
  module: {
    loaders: [
      { test: /\.css$/, loader: 'style!css' },
      { test: /\.less$/, loader: 'style!css!less' },
      { test: /\.tsx?$/, loaders: ['react-hot', 'ts'], include: path.join(__dirname, 'src') },
      { test: /index\.html$/, loader: 'file?name=[name].[ext]' }
    ]
  },
  resolve: {
    extensions: ['', '.ts', '.tsx', '.webpack.js', '.web.js', '.js']
  },
  stats: {
    colors: true,
    modules: true,
    reasons: true
  },
  progress: true,
  failOnError: true
};
<commit_msg>webpack fix to support bootstrap fonts<commit_after>var path = require('path');
var webpack = require('webpack');

var plugins = [];
var output = 'build';

var isProduction = process.argv.indexOf('-p') >= 0 ? true : false;

if (isProduction) {
  output = 'dist';

  plugins.push(new webpack.optimize.UglifyJsPlugin({minimize: true}));
}

module.exports = {
  entry: [
    './src/index.tsx',
    './index.html'
  ],
  output: {
    path: path.join(__dirname, output),
    filename: 'app.js'
  },
  plugins: plugins,
  module: {
    loaders: [
      { test: /\.css$/, loader: 'style!css' },
      { test: /\.less$/, loader: 'style!css!less' },
      { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
      { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
      { test: /\.tsx?$/, loaders: ['react-hot', 'ts'], include: path.join(__dirname, 'src') },
      { test: /index\.html$/, loader: 'file?name=[name].[ext]' }
    ]
  },
  resolve: {
    extensions: ['', '.ts', '.tsx', '.webpack.js', '.web.js', '.js']
  },
  stats: {
    colors: true,
    modules: true,
    reasons: true
  },
  progress: true,
  failOnError: true
};
<|endoftext|>


<commit_before>const webpack = require("webpack")
const path = require("path")
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const autoprefixer = require("autoprefixer")

const devServer = {
  host: "0.0.0.0",
  port: "3000",
}

module.exports = function (env) {
  const debug = env !== 'prod'

  return {
    entry: debug ? [
      "react-hot-loader/patch",
      "./src/index.js"
    ] : [
      "./src/index.js"
    ],

    output: {
      path: path.join(__dirname, "public/static"),
      filename: "bundle.js",
      publicPath: "/static/"
    },

    devtool: "source-map",

    module: {
      rules: [

        {
          test: /\.js$/,
          exclude: /node_modules/,
          enforce: "pre",
          loader: "eslint-loader",
        },

        {
          test: /\.js?$/,
          use: "babel-loader",
          include: path.join(__dirname, "src")
        },

        {
          test: /\.(woff(2)?|png|jpg|gif)(\?[a-z0-9=\.]+)?$/,
          loader: "url-loader",
          query: {
            limit: "10000"
          }
        },

        {
          test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
          loader: "file-loader"
        },

        {
          test: /\.css$/,
          use: (debug)
            ? [
              "style-loader",
              {
                loader: "css-loader",
                options: {
                  modules: true,
                  importLoaders: 1,
                  localIdentName: "[path][name]__[local]--[hash:base64:5]"
                }
              },
              "postcss-loader",
            ]
            : ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: [
                  {
                    loader: "css-loader",
                    options: {
                      modules: true,
                      importLoaders: 1,
                      localIdentName: "[path][name]__[local]___[hash:base64:5]"
                    }
                  },
                  "postcss-loader",
                ],
              })
        }
      ],
    },

    devServer: {
      hot: true,
      historyApiFallback: true,
      host: "0.0.0.0",
      port: "3000",
      contentBase: path.join(__dirname, "public"),
      publicPath: "/static/",
      stats: { colors: true },
      inline: true,
    },

    resolve: {
      modules: [
        path.join(__dirname, "src"),
        "node_modules",
      ]
    },

    plugins: debug
      ? [
        new webpack.HotModuleReplacementPlugin(),
      ]
      : [
        new ExtractTextPlugin({
          filename: "style.css"
        }),
        new webpack.DefinePlugin({
          "process.env":{
            "NODE_ENV": JSON.stringify("production")
          }
        }),
        new webpack.optimize.UglifyJsPlugin({
          mangle: false,
          sourceMap: false,
          compress: {
            warnings: true
          }
        }),
      ]

  }
}
<commit_msg>webpack urlloader<commit_after>const webpack = require("webpack")
const path = require("path")
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const autoprefixer = require("autoprefixer")

module.exports = function (env) {
  const debug = env !== 'prod'

  return {
    entry: debug ? [
      "react-hot-loader/patch",
      "./src/index.js"
    ] : [
      "./src/index.js"
    ],

    output: {
      path: path.join(__dirname, "public/static"),
      filename: "bundle.js",
      publicPath: "/static/"
    },

    devtool: "source-map",

    module: {
      rules: [

        {
          test: /\.js$/,
          exclude: /node_modules/,
          enforce: "pre",
          loader: "eslint-loader",
        },

        {
          test: /\.js?$/,
          use: "babel-loader",
          include: path.join(__dirname, "src")
        },

        {
          test: /\.(woff(2)?|png|jpg|gif|svg)(\?[a-z0-9=\.]+)?$/,
          use: [
            {
              loader: 'url-loader',
              options: {
                limit: '100000',
              }
            }
          ],
          include: path.join(__dirname, "src")
        },

        {
          test: /\.(ttf|eot|webm|mp4)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
          loader: "file-loader"
        },

        {
          test: /\.css$/,
          use: (debug)
            ? [
              "style-loader",
              {
                loader: "css-loader",
                options: {
                  modules: true,
                  importLoaders: 1,
                  localIdentName: "[path][name]__[local]--[hash:base64:5]"
                }
              },
              "postcss-loader",
            ]
            : ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: [
                  {
                    loader: "css-loader",
                    options: {
                      modules: true,
                      importLoaders: 1,
                      localIdentName: "[path][name]__[local]___[hash:base64:5]"
                    }
                  },
                  "postcss-loader",
                ],
              })
        }
      ],
    },

    devServer: {
      hot: true,
      historyApiFallback: true,
      host: "0.0.0.0",
      port: "3000",
      contentBase: path.join(__dirname, "public"),
      publicPath: "/static/",
      stats: { colors: true },
      inline: true,
    },

    resolve: {
      modules: [
        path.join(__dirname, "src"),
        "node_modules",
      ]
    },

    plugins: debug
      ? [
        new webpack.HotModuleReplacementPlugin(),
      ]
      : [
        new ExtractTextPlugin({
          filename: "style.css"
        }),
        new webpack.DefinePlugin({
          "process.env":{
            "NODE_ENV": JSON.stringify("production")
          }
        }),
        new webpack.optimize.UglifyJsPlugin({
          mangle: false,
          sourceMap: false,
          compress: {
            warnings: true
          }
        }),
      ]

  }
}
<|endoftext|>


<commit_before>// @ts-check

"use strict";

// Webpack will output the following warnings when building:
//
// WARNING in ./node_modules/ws/lib/buffer-util.js
// Module not found: Error: Can't resolve 'bufferutil' in '/Users/dantup/Dev/Dart-Code/node_modules/ws/lib'
//
// WARNING in ./node_modules/ws/lib/validation.js
// Module not found: Error: Can't resolve 'utf-8-validate' in '/Users/dantup/Dev/Dart-Code/node_modules/ws/lib'
//
// These are caused by ws require()ing those two modules and they're not listed
// in our dependencies. Info on the reason for this is here:
// https://github.com/websockets/ws/blob/5d751fbd4c0ab3478a6de4194d4d06908bc8ac00/README.md#opt-in-for-performance-and-spec-compliance
//
// It appears to be safe to ignore these as they're being loaded in a try{} block
// and are optional.

// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

module.exports = (env) => {
	/**
	 * @type {import("webpack").Configuration}
	 */
	const config = {
		devtool: "source-map",
		entry: {
			extension: "./src/extension/extension.ts",
			debug: "./src/debug/debug_entry.ts",
		},
		// https://webpack.js.org/configuration/externals/
		externals: {
			vscode: "commonjs vscode",
		},
		module: {
			rules: [{
				exclude: /node_modules/,
				test: /\.ts$/,
				loader: "ts-loader",
			}],
		},
		output: {
			devtoolModuleFilenameTemplate: "../../[resource-path]",
			libraryTarget: "commonjs2",
			path: path.resolve(__dirname, "out/dist"),
		},
		resolve: {
			extensions: [".ts", ".js"],
		},
		target: "node",
	};

	if (env && env.instrumentation) {
		config.module.rules.push({
			enforce: "post",
			exclude: /node_modules/,
			test: /\.ts$/,
			loader: "istanbul-instrumenter-loader",
		});
	}

	return config;
};
<commit_msg>Disable minification for production builds<commit_after>// @ts-check

"use strict";

// Webpack will output the following warnings when building:
//
// WARNING in ./node_modules/ws/lib/buffer-util.js
// Module not found: Error: Can't resolve 'bufferutil' in '/Users/dantup/Dev/Dart-Code/node_modules/ws/lib'
//
// WARNING in ./node_modules/ws/lib/validation.js
// Module not found: Error: Can't resolve 'utf-8-validate' in '/Users/dantup/Dev/Dart-Code/node_modules/ws/lib'
//
// These are caused by ws require()ing those two modules and they're not listed
// in our dependencies. Info on the reason for this is here:
// https://github.com/websockets/ws/blob/5d751fbd4c0ab3478a6de4194d4d06908bc8ac00/README.md#opt-in-for-performance-and-spec-compliance
//
// It appears to be safe to ignore these as they're being loaded in a try{} block
// and are optional.

// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

module.exports = (env) => {
	/**
	 * @type {import("webpack").Configuration}
	 */
	const config = {
		devtool: "source-map",
		entry: {
			extension: "./src/extension/extension.ts",
			debug: "./src/debug/debug_entry.ts",
		},
		// https://webpack.js.org/configuration/externals/
		externals: {
			vscode: "commonjs vscode",
		},
		module: {
			rules: [{
				exclude: /node_modules/,
				test: /\.ts$/,
				loader: "ts-loader",
			}],
		},
		output: {
			devtoolModuleFilenameTemplate: "../../[resource-path]",
			libraryTarget: "commonjs2",
			path: path.resolve(__dirname, "out/dist"),
		},
		optimization: {
			minimize: false,
		},
		resolve: {
			extensions: [".ts", ".js"],
		},
		target: "node",
	};

	if (env && env.instrumentation) {
		config.module.rules.push({
			enforce: "post",
			exclude: /node_modules/,
			test: /\.ts$/,
			loader: "istanbul-instrumenter-loader",
		});
	}

	return config;
};
<|endoftext|>


<commit_before>const path = require("path");
const webpack = require("webpack");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const PreloadWebpackPlugin = require("preload-webpack-plugin");
const ShellOnBuildEndPlugin = require("./webpack-util/shell-on-build-end-webpack-plugin");

const { config } = require("./config/build");

if (!process.env.HIDE_CONFIG) {
  console.log("CONFIG = ", config); // eslint-disable-line no-console
}

const DEV = process.env.NODE_ENV === "development";
const PROD = process.env.NODE_ENV === "production";

module.exports = {
  // Defaults to development, pass --mode production to override
  mode: "development",

  context: path.resolve(__dirname),

  target: "web",

  entry: {
    app: "./src/index.tsx",
  },

  output: {
    filename: "[name].[hash:7].js",
    path: path.resolve(__dirname, "dist"),
    publicPath: config.url.publicPath,
  },

  module: {
    rules: [
      // Vanilla CSS
      {
        test: /\.css$/,
        include: path.resolve(__dirname, "src"),
        loaders: ["style-loader", "css-loader"],
      },
      // PostCSS
      {
        test: /\.scss$/,
        include: path.resolve(__dirname, "src"),
        loaders: [
          "style-loader",
          {
            loader: "css-loader",
            options: { modules: true, importLoaders: 1 },
          },
          "postcss-loader",
        ],
      },
      {
        test: /\.(jpg|jpeg|png|gif|mp4|webm|mp3|ogg|svg)$/,
        loader: "file-loader",
        options: {
          name: "./f/[hash:16].[ext]",
        },
      },
      {
        test: /\.(j|t)sx?$/,
        exclude: /\/node_modules\//,
        loader: "babel-loader",
        options: {
          cacheDirectory: true,
        },
      },
    ],
  },

  plugins: [
    // Inject app config at build-time: see comments in config/index.ts for details
    new webpack.DefinePlugin({
      __WEBPACK_DEFINE_CONFIG_JS_OBJ__: JSON.stringify(config),
    }),
    new webpack.NamedModulesPlugin(),
    ...(DEV
      ? [
          new ShellOnBuildEndPlugin({
            command: "yarn --silent tsc:check:no-error --pretty",
            killExisting: true,
          }),
        ]
      : []),
    new CircularDependencyPlugin({
      allowAsyncCycles: false,
      cwd: process.cwd(),
      exclude: /node_modules/,
      failOnError: true,
    }),
    new HtmlWebpackPlugin({
      template: "./src/index.html",
      favicon: "./src/static/favicon.ico",
    }),
    // Add resource hints to reduce loadtime
    // Ignore chunks at top level: if wanted, use the commented config instead
    // new PreloadWebpackPlugin({
    //   rel: "preload",
    //   include: "allChunks"
    // }),
    new PreloadWebpackPlugin({
      rel: "preload",
      include: "allAssets",
      fileWhitelist: [/\.(woff|woff2|ttf|svg|eot|otf|json|js)/],
    }),
    // Generate .gz for production builds
    // Consider adding brotli-webpack-plugin if your server supports .br
    ...(PROD
      ? [
          new CompressionPlugin({
            include: /\.(js|html|svg)$/,
          }),
        ]
      : []),
  ],

  // Using inline-source-map for detailed line numbers
  // Switch to cheap-eval-source-map if build times are too long
  devtool: PROD ? false : "inline-source-map",

  devServer: {
    allowedHosts: ["localhost"],
    clientLogLevel: "warning",
    historyApiFallback: true,
    host: "localhost",
    publicPath: config.url.publicPath,
    stats: "minimal",
  },

  externals: {
    cheerio: "window",
    "react/addons": true,
    "react/lib/ExecutionEnvironment": true,
    "react/lib/ReactContext": true,
  },

  resolve: {
    extensions: [".js", ".jsx", ".ts", ".tsx"],
    modules: ["node_modules", path.resolve(__dirname, "src")],
    alias: {
      "@cfg": path.resolve(__dirname, "config"),
      "@src": path.resolve(__dirname, "src"),
      "@test": path.resolve(__dirname, "test"),
      ...(DEV ? { "react-dom": "@hot-loader/react-dom" } : {}),
    },
  },
};
<commit_msg>perf: Remove tsc:check on dev build<commit_after>const path = require("path");
const webpack = require("webpack");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const PreloadWebpackPlugin = require("preload-webpack-plugin");

const { config } = require("./config/build");

if (!process.env.HIDE_CONFIG) {
  console.log("CONFIG = ", config); // eslint-disable-line no-console
}

const DEV = process.env.NODE_ENV === "development";
const PROD = process.env.NODE_ENV === "production";

module.exports = {
  // Defaults to development, pass --mode production to override
  mode: "development",

  context: path.resolve(__dirname),

  target: "web",

  entry: {
    app: "./src/index.tsx",
  },

  output: {
    filename: "[name].[hash:7].js",
    path: path.resolve(__dirname, "dist"),
    publicPath: config.url.publicPath,
  },

  module: {
    rules: [
      // Vanilla CSS
      {
        test: /\.css$/,
        include: path.resolve(__dirname, "src"),
        loaders: ["style-loader", "css-loader"],
      },
      // PostCSS
      {
        test: /\.scss$/,
        include: path.resolve(__dirname, "src"),
        loaders: [
          "style-loader",
          {
            loader: "css-loader",
            options: { modules: true, importLoaders: 1 },
          },
          "postcss-loader",
        ],
      },
      {
        test: /\.(jpg|jpeg|png|gif|mp4|webm|mp3|ogg|svg)$/,
        loader: "file-loader",
        options: {
          name: "./f/[hash:16].[ext]",
        },
      },
      {
        test: /\.(j|t)sx?$/,
        exclude: /\/node_modules\//,
        loader: "babel-loader",
        options: {
          cacheDirectory: true,
        },
      },
    ],
  },

  plugins: [
    // Inject app config at build-time: see comments in config/index.ts for details
    new webpack.DefinePlugin({
      __WEBPACK_DEFINE_CONFIG_JS_OBJ__: JSON.stringify(config),
    }),
    new webpack.NamedModulesPlugin(),
    new CircularDependencyPlugin({
      allowAsyncCycles: false,
      cwd: process.cwd(),
      exclude: /node_modules/,
      failOnError: true,
    }),
    new HtmlWebpackPlugin({
      template: "./src/index.html",
      favicon: "./src/static/favicon.ico",
    }),
    // Add resource hints to reduce loadtime
    // Ignore chunks at top level: if wanted, use the commented config instead
    // new PreloadWebpackPlugin({
    //   rel: "preload",
    //   include: "allChunks"
    // }),
    new PreloadWebpackPlugin({
      rel: "preload",
      include: "allAssets",
      fileWhitelist: [/\.(woff|woff2|ttf|svg|eot|otf|json|js)/],
    }),
    // Generate .gz for production builds
    // Consider adding brotli-webpack-plugin if your server supports .br
    ...(PROD
      ? [
          new CompressionPlugin({
            include: /\.(js|html|svg)$/,
          }),
        ]
      : []),
  ],

  // Using inline-source-map for detailed line numbers
  // Switch to cheap-eval-source-map if build times are too long
  devtool: PROD ? false : "inline-source-map",

  devServer: {
    allowedHosts: ["localhost"],
    clientLogLevel: "warning",
    historyApiFallback: true,
    host: "localhost",
    publicPath: config.url.publicPath,
    stats: "minimal",
  },

  externals: {
    cheerio: "window",
    "react/addons": true,
    "react/lib/ExecutionEnvironment": true,
    "react/lib/ReactContext": true,
  },

  resolve: {
    extensions: [".js", ".jsx", ".ts", ".tsx"],
    modules: ["node_modules", path.resolve(__dirname, "src")],
    alias: {
      "@cfg": path.resolve(__dirname, "config"),
      "@src": path.resolve(__dirname, "src"),
      "@test": path.resolve(__dirname, "test"),
      ...(DEV ? { "react-dom": "@hot-loader/react-dom" } : {}),
    },
  },
};
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const merge = require('webpack-merge');

const TARGETS = {
    START_DEV: 'start-dev',
    BUILD: 'build',
};
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
    PUBLIC: path.join(__dirname, 'PUBLIC'),
    BUILD: path.join(__dirname, 'build'),
    DIST: path.join(__dirname, 'dist'),
    NODE_MODULES: path.join(__dirname, 'node_modules'),
};

const extractCss = new ExtractTextPlugin('vendor-[hash].css');
const extractStyl = new ExtractTextPlugin('app-[hash].css');

const common = {
    module: {
        loaders: [
            {
                test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'url?limit=10000&mimetype=application/font-woff',
            },
            {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'url?limit=10000&mimetype=application/octet-stream',
            },
            {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'file',
            },
            {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'file',
            },
        ],
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: 'public/index.html',
            inject: 'body',
            filename: 'index.html',
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
    ],
    resolve: {
        extensions: ['', '.js', '.jsx'],
    },
};

if (TARGET === TARGETS.START_DEV) {
    module.exports = merge(common, {
        devtool: 'eval-source-map',
        entry: [
            'webpack-hot-middleware/client?reload=true',
            PATHS.PUBLIC,
        ],
        output: {
            path: PATHS.BUILD,
            filename: '[name].js',
        },
        module: {
            preLoaders: [
                {
                    test: /\.(js|jsx)$/,
                    loader: 'eslint',
                    include: PATHS.PUBLIC,
                },
            ],
            loaders: [
                {
                    test: /\.css$/,
                    loaders: ['style', 'css'],
                },
                {
                    test: /\.styl$/,
                    loaders: ['style', 'css', 'stylus'],
                    include: PATHS.PUBLIC,
                },
                {
                    test: /\.(js|jsx)$/,
                    loaders: ['react-hot', 'babel'],
                    include: PATHS.PUBLIC,
                },
            ],
        },
        plugins: [
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NoErrorsPlugin(),
        ],
    });
}

if (TARGET === TARGETS.BUILD) {
    module.exports = merge.smart(common, {
        entry: {
            app: PATHS.PUBLIC,
            vendor: [
                'react', 'moment', 'react-bootstrap', 'react-dom', 'flux', 'react-router', 'react-toastr', 'superagent',
                'classnames', 'jwt-decode',
            ],
        },
        output: {
            path: PATHS.DIST,
            filename: '[name]-[hash].min.js',
        },
        module: {
            loaders: [
                {
                    test: /\.css$/,
                    loader: extractCss.extract('style', ['css', 'postcss']),
                },
                {
                    test: /\.styl$/,
                    loader: extractStyl.extract('style', ['css', 'postcss', 'stylus']),
                },
                {
                    test: /\.(js|jsx)$/,
                    loader: 'babel',
                    include: PATHS.PUBLIC,
                },
            ],
        },
        plugins: [
            new webpack.optimize.UglifyJsPlugin({
                compressor: {
                    warnings: false,
                    screw_ie8: true,
                },
            }),
            new StatsPlugin('webpack.stats.json', {
                source: false,
                modules: false,
            }),
            extractCss,
            extractStyl,
        ],
        postcss: () => [autoprefixer],
    });
}
<commit_msg>disable eslint for webpack<commit_after>const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const merge = require('webpack-merge');

const TARGETS = {
    START_DEV: 'start-dev',
    BUILD: 'build',
};
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
    PUBLIC: path.join(__dirname, 'public'),
    BUILD: path.join(__dirname, 'build'),
    DIST: path.join(__dirname, 'dist'),
    NODE_MODULES: path.join(__dirname, 'node_modules'),
};

const extractCss = new ExtractTextPlugin('vendor-[hash].css');
const extractStyl = new ExtractTextPlugin('app-[hash].css');

const common = {
    module: {
        loaders: [
            {
                test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'url?limit=10000&mimetype=application/font-woff',
            },
            {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'url?limit=10000&mimetype=application/octet-stream',
            },
            {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'file',
            },
            {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                loader: 'file',
            },
        ],
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: 'public/index.html',
            inject: 'body',
            filename: 'index.html',
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
    ],
    resolve: {
        extensions: ['', '.js', '.jsx'],
    },
};

if (TARGET === TARGETS.START_DEV) {
    module.exports = merge(common, {
        devtool: 'eval-source-map',
        entry: [
            'webpack-hot-middleware/client?reload=true',
            PATHS.PUBLIC,
        ],
        output: {
            path: PATHS.BUILD,
            filename: '[name].js',
        },
        module: {
            // preLoaders: [
            //     {
            //         test: /\.(js|jsx)$/,
            //         loader: 'eslint',
            //         include: PATHS.PUBLIC,
            //     },
            // ],
            loaders: [
                {
                    test: /\.css$/,
                    loaders: ['style', 'css'],
                },
                {
                    test: /\.styl$/,
                    loaders: ['style', 'css', 'stylus'],
                    include: PATHS.PUBLIC,
                },
                {
                    test: /\.(js|jsx)$/,
                    loaders: ['react-hot', 'babel'],
                    include: PATHS.PUBLIC,
                },
            ],
        },
        plugins: [
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NoErrorsPlugin(),
        ],
    });
}

if (TARGET === TARGETS.BUILD) {
    module.exports = merge.smart(common, {
        entry: {
            app: PATHS.PUBLIC,
            vendor: [
                'react', 'moment', 'react-bootstrap', 'react-dom', 'flux', 'react-router', 'react-toastr', 'superagent',
                'classnames', 'jwt-decode',
            ],
        },
        output: {
            path: PATHS.DIST,
            filename: '[name]-[hash].min.js',
        },
        module: {
            loaders: [
                {
                    test: /\.css$/,
                    loader: extractCss.extract('style', ['css', 'postcss']),
                },
                {
                    test: /\.styl$/,
                    loader: extractStyl.extract('style', ['css', 'postcss', 'stylus']),
                },
                {
                    test: /\.(js|jsx)$/,
                    loader: 'babel',
                    include: PATHS.PUBLIC,
                },
            ],
        },
        plugins: [
            new webpack.optimize.UglifyJsPlugin({
                compressor: {
                    warnings: false,
                    screw_ie8: true,
                },
            }),
            new StatsPlugin('webpack.stats.json', {
                source: false,
                modules: false,
            }),
            extractCss,
            extractStyl,
        ],
        postcss: () => [autoprefixer],
    });
}
<|endoftext|>


<commit_before>var argv = require('yargs').argv
var path = require('path')
var webpack = require('webpack')
var CommonsChunkPlugin = require(__dirname + '/node_modules/webpack/lib/optimize/CommonsChunkPlugin')

// Create plugins array
var plugins = [
  new CommonsChunkPlugin('commons.js')
]

// Add Uglify task to plugins array if there is a production flag
if (argv.production) {
  plugins.push(new webpack.optimize.UglifyJsPlugin())
}

module.exports = {
  entry: {
    home: __dirname + '/src/js/page-generic',
    generic: __dirname + '/src/js/page-generic',
    findhelp: __dirname + '/src/js/page-find-help',
    category: __dirname + '/src/js/page-category',
    categorybyday: __dirname + '/src/js/page-category-by-day',
    organisation: __dirname + '/src/js/page-organisation',
    allserviceproviders: __dirname + '/src/js/page-all-service-providers',
    giveitems: __dirname + '/src/js/page-give-items',
    giveitemsubmitdetails: __dirname + '/src/js/page-give-item-submit-details',
    sponsor: __dirname + '/src/js/page-sponsor',
    volunteer: __dirname + '/src/js/page-volunteer',
    joinstreetsupport: __dirname + '/src/js/page-join-street-support'
  },
  output: {
    path: path.join(__dirname, '/_dist/assets/js/'),
    filename: '[name].bundle.js',
    chunkFilename: '[id].chunk.js',
    publicPath: 'assets/js/'
  },
  plugins: plugins,
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel',
        exclude: /(node_modules|bower_components)/
      }
    ]
  },
  standard: {
    parser: 'babel-eslint'
  }
}
<commit_msg>fix babel not working with webpack<commit_after>var argv = require('yargs').argv
var path = require('path')
var webpack = require('webpack')
var CommonsChunkPlugin = require(__dirname + '/node_modules/webpack/lib/optimize/CommonsChunkPlugin')

// Create plugins array
var plugins = [
  new CommonsChunkPlugin('commons.js')
]

// Add Uglify task to plugins array if there is a production flag
if (argv.production) {
  plugins.push(new webpack.optimize.UglifyJsPlugin())
}

module.exports = {
  entry: {
    home: __dirname + '/src/js/page-generic',
    generic: __dirname + '/src/js/page-generic',
    findhelp: __dirname + '/src/js/page-find-help',
    category: __dirname + '/src/js/page-category',
    categorybyday: __dirname + '/src/js/page-category-by-day',
    organisation: __dirname + '/src/js/page-organisation',
    allserviceproviders: __dirname + '/src/js/page-all-service-providers',
    giveitems: __dirname + '/src/js/page-give-items',
    giveitemsubmitdetails: __dirname + '/src/js/page-give-item-submit-details',
    sponsor: __dirname + '/src/js/page-sponsor',
    volunteer: __dirname + '/src/js/page-volunteer',
    joinstreetsupport: __dirname + '/src/js/page-join-street-support'
  },
  output: {
    path: path.join(__dirname, '/_dist/assets/js/'),
    filename: '[name].bundle.js',
    chunkFilename: '[id].chunk.js',
    publicPath: 'assets/js/'
  },
  plugins: plugins,
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['es2015']
        }
      }
    ]
  },
  standard: {
    parser: 'babel-eslint'
  }
}
<|endoftext|>


<commit_before>
import { and, or, not } from './';

const $in = value => arr => Array.contains(arr, value);
const $nin = value => arr => !Array.contains(arr, value);
const $ne = value => key => key !== value;
const $eq = value => key => key === value;
const $lt = value => key => key < value;
const $lte = value => key => key <= value;
const $gt = value => key => key > value;
const $gte = value => key => key >= value;
const $mod = (divisor, remainder) => v => v % divisor === (remainder || 0);

const $obj = (predicates) => model => {
  for (let key in predicates) {
    if (predicates.hasOwnProperty(key)) {
      if (!predicates[key](model[key])) return false;
    }
  }
  return true;
}

const predicate = and($obj({x: $gt(5)}),
                      $obj({y: $gt(5)}));

console.log(predicate({x: 13, y: 10}));

// const predicate = and($mod(2),
//                       $mod(3),
//                       or($gt(50),
//                          not($gt(20))));

// console.log(predicate(60))<commit_msg>working on library<commit_after>
import { and, or, not } from './';

const $in = value => arr => Array.contains(arr, value);
const $nin = value => arr => !Array.contains(arr, value);
const $ne = value => key => key !== value;
const $eq = value => key => key === value;
const $lt = value => key => key < value;
const $lte = value => key => key <= value;
const $gt = value => key => key > value;
const $gte = value => key => key >= value;
const $mod = (divisor, remainder) => v => v % divisor === (remainder || 0);

const _$ = (predicates) => model => {
  for (let key in predicates) {
    if (predicates.hasOwnProperty(key)) {
      if (!predicates[key](model[key])) return false;
    }
  }
  return true;
}

const predicate = and(_$({x: $gt(5)}),
                      _$({y: $gt(5)}));

console.log(predicate({x: 13, y: 10}));

// const predicate = and($mod(2),
//                       $mod(3),
//                       or($gt(50),
//                          not($gt(20))));

// console.log(predicate(60))<|endoftext|>


<commit_before>'use strict';

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: './browser/react/index.js',
  output: {
    path: path.join(__dirname, 'public'),
    publicPath: '/',
    filename: './bundle.js'
  },
  context: __dirname,
  devtool: 'source-map',
  resolve: {
    extensions: ['', '.js', '.jsx', '.scss']
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: false,
      mangle: false
    })
  ],
  module: {
    loaders: [
      {
        test: /jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015', 'stage-2']
        }
      },
      {test: /\.scss?$/, loaders: ['style', 'css', 'sass']},
      {
        test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?.*$|$)/,
        loader: 'file'
      }
    ]
  },
  stats: {
    warnings: false
  }
};
<commit_msg>fixed heroku start bugs<commit_after>'use strict';

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: './browser/react/index.js',
  output: {
    path: path.join(__dirname, 'public'),
    publicPath: '/',
    filename: './bundle.js'
  },
  context: __dirname,
  devtool: 'source-map',
  resolve: {
    extensions: ['', '.js', '.jsx', '.scss']
  },
  // plugins: [
  //   new webpack.DefinePlugin({
  //     'process.env': {
  //       NODE_ENV: JSON.stringify('production')
  //     }
  //   }),
  //   new webpack.optimize.UglifyJsPlugin({
  //     sourceMap: false,
  //     mangle: false
  //   })
  // ],
  module: {
    loaders: [
      {
        test: /jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015', 'stage-2']
        }
      },
      {test: /\.scss?$/, loaders: ['style', 'css', 'sass']},
      {
        test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?.*$|$)/,
        loader: 'file'
      }
    ]
  },
  stats: {
    warnings: false
  }
};
<|endoftext|>


<commit_before>/* global __dirname */

var path = require('path');

var webpack = require('webpack');

var CopyWebpackPlugin = require('copy-webpack-plugin');

var dir_js = path.resolve(__dirname, 'js');
var dir_html = path.resolve(__dirname, 'html');
var dir_build = path.resolve(__dirname, 'build');

module.exports = {
    entry: path.resolve(dir_js, 'main.js'),
    output: {
        path: dir_build,
        filename: 'bundle.js'
    },
    devServer: {
        contentBase: dir_build,
    },
    module: {
        loaders: [
            {
                loader: 'react-hot',
                test: dir_js,
            },
            {
                loader: 'babel-loader',
                test: dir_js,
                query: {
                    presets: ['es2015', 'react'],
                },
            }
        ]
    },
    plugins: [
        // Simply copies the files over
        new CopyWebpackPlugin([
            { from: dir_html } // to: output.path
        ]),
        // Avoid publishing files when compilation fails
        new webpack.NoErrorsPlugin(),
        new webpack.DefinePlugin({
            "process.env": {
                NODE_ENV: JSON.stringify("production")
            }
        })
    ],
    stats: {
        // Nice colored output
        colors: true
    },
    // Create Sourcemaps for the bundle
    devtool: 'source-map',
};
<commit_msg>define<commit_after>/* global __dirname */

var path = require('path');

var webpack = require('webpack');

var CopyWebpackPlugin = require('copy-webpack-plugin');

var dir_js = path.resolve(__dirname, 'js');
var dir_html = path.resolve(__dirname, 'html');
var dir_build = path.resolve(__dirname, 'build');

module.exports = {
    entry: path.resolve(dir_js, 'main.js'),
    output: {
        path: dir_build,
        filename: 'bundle.js'
    },
    devServer: {
        contentBase: dir_build,
    },
    module: {
        loaders: [
            {
                loader: 'react-hot',
                test: dir_js,
            },
            {
                loader: 'babel-loader',
                test: dir_js,
                query: {
                    presets: ['es2015', 'react'],
                },
            }
        ]
    },
    plugins: [
        // Simply copies the files over
                new webpack.DefinePlugin({
            "process.env": {
                NODE_ENV: JSON.stringify("production")
            }
        }),
        new CopyWebpackPlugin([
            { from: dir_html } // to: output.path
        ]),
        // Avoid publishing files when compilation fails
        new webpack.NoErrorsPlugin(),
    ],
    stats: {
        // Nice colored output
        colors: true
    },
    // Create Sourcemaps for the bundle
    devtool: 'source-map',
};
<|endoftext|>


<commit_before>var webpack = require('webpack');
var path = require('path');
var cleanWebpackPlugin = require('webpack-cleanup-plugin');
module.exports = {
  entry: [
    './src/index'
  ],
  module: {
    loaders: [
      {
        test: /\.js?$/,
        loader: 'babel',
        exclude: /node_modules/
      },

      {
        test: /\.scss$/,
        loader: 'style!css!sass'
       },{
        test: /\.css$/,
        loader: "style-loader!css-loader"
      },
      {
        test: /\.png$/,
        loader: "url-loader?limit=100000"
      },
      {
        test: /\.jpg$/,
        loader: "file-loader"
      },
      {
        test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/font-woff'
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/octet-stream'
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'file'
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=image/svg+xml'
      }
    ]
  },
  resolve: {
    extensions: ['', '.js','.jsx']
  },
  output: {
    path: path.join(__dirname, '/dist'),
    publicPath: '/',
    filename: 'bundle.js'
  },
  devServer: {
    contentBase: './dist',
    hot: true
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new cleanWebpackPlugin(['dist'],{
      verbose:true,
      dry:false,
      exclude:['index.html']
    })
  ]
};<commit_msg>ups yeah forgot about the webpack.config.js<commit_after>var webpack = require('webpack');
var path = require('path');
module.exports = {
  entry: [
    './src/index'
  ],
  module: {
    loaders: [
      {
        test: /\.js?$/,
        loader: 'babel',
        exclude: /node_modules/
      },

      {
        test: /\.scss$/,
        loader: 'style!css!sass'
       },{
        test: /\.css$/,
        loader: "style-loader!css-loader"
      },
      {
        test: /\.png$/,
        loader: "url-loader?limit=100000"
      },
      {
        test: /\.jpg$/,
        loader: "file-loader"
      },
      {
        test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/font-woff'
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/octet-stream'
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'file'
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=image/svg+xml'
      }
    ]
  },
  resolve: {
    extensions: ['', '.js','.jsx']
  },
  output: {
    path: path.join(__dirname, '/dist'),
    publicPath: '/',
    filename: 'bundle.js'
  },
  devServer: {
    contentBase: './dist',
    hot: true
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
  ]
};<|endoftext|>


<commit_before>'use strict';
const webpack=require('webpack');
const compression = require('compression-webpack-plugin');
const html = require('html-webpack-plugin');
const jade = require('jade');
const prod = process.env.NODE_ENV === 'production';
const basename = require('path').basename(__dirname);
const base = prod ? `/${basename}/` : `/${basename}_dev/`;
const config = {
  entry: {
    app: './src',
    vendors: [
      'angular-ui-router',
      'angular-ui-router.statehelper',
      'angular-ui-bootstrap',
      'oclazyload',
      'api-check',
      'angular-formly',
      'angular-formly-templates-bootstrap',
      'angular-permission',
      'ngstorage'
    ]
  },
  output: {
    filename: 'app.js',
    path: './dist',
    publicPath: base+'dist/'
  },
  module: {
    preLoaders: [
      {
        loader: 'source-map',
        include: [/angular-file-upload/]
      }
    ],
    noParse: [
      /angular-file-upload/
    ],
    loaders: [
      {
        loader: 'ng-annotate?add!babel?presets[]=es2015!eslint',
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/
      },
      {
        loader: 'style!css',
        test: /\.css$/
      },
      {
        loader: `ngtemplate?relativeTo=src/&prefix=dist/!template-html?engine=jade&doctype=html&basedir=${__dirname}/src`,
        test: /\.jade$/,
        exclude: /(node_modules|bower_components)/
      },
      {
        loader: 'json!yaml',
        test: /\.yml$/,
        exclude: /(node_modules|bower_components)/
      }
    ]
  },
  externals: {
    angular: 'angular',
    lodash: '_',
    MathJax: 'MathJax'
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
    new html({
      title: 'Statistik für Jedermann',
      templateContent: jade.compileFile(__dirname+'/src/index.jade'),
      inject: 'head',
      base,
      prod,
      versions: {
        angular: '1.4.7',
        bootstrap: '3.3.5',
        fontAwesome: '4.4.0',
        lodash: '3.10.1',
        restangular: '1.5.1',
      }
    })
  ],
  devtool: 'source-map',
  devServer: {
    port: 9000,
    host: '0.0.0.0',
    proxy: {
      '*': {
        target: 'http://localhost:3000',
        rewrite: function(req){
          req.url = req.url.replace(base,'/');
        }
      }
    }
  }
};
if(prod){
  config.plugins.push(
    new webpack.optimize.DedupePlugin(),
    new compression()
  );
}
module.exports = config;
<commit_msg>Add json loader for markdown-it<commit_after>'use strict';
const webpack=require('webpack');
const compression = require('compression-webpack-plugin');
const html = require('html-webpack-plugin');
const jade = require('jade');
const prod = process.env.NODE_ENV === 'production';
const basename = require('path').basename(__dirname);
const base = prod ? `/${basename}/` : `/${basename}_dev/`;
const config = {
  entry: {
    app: './src',
    vendors: [
      'angular-ui-router',
      'angular-ui-router.statehelper',
      'angular-ui-bootstrap',
      'oclazyload',
      'api-check',
      'angular-formly',
      'angular-formly-templates-bootstrap',
      'angular-permission',
      'ngstorage'
    ]
  },
  output: {
    filename: 'app.js',
    path: './dist',
    publicPath: base+'dist/'
  },
  module: {
    preLoaders: [
      {
        loader: 'source-map',
        include: [/angular-file-upload/]
      }
    ],
    noParse: [
      /angular-file-upload/
    ],
    loaders: [
      {
        loader: 'ng-annotate?add!babel?presets[]=es2015!eslint',
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/
      },
      {
        loader: 'style!css',
        test: /\.css$/
      },
      {
        loader: `ngtemplate?relativeTo=src/&prefix=dist/!template-html?engine=jade&doctype=html&basedir=${__dirname}/src`,
        test: /\.jade$/,
        exclude: /(node_modules|bower_components)/
      },
      {
        loader: 'json',
        test: /\.json$/
      },
      {
        loader: 'json!yaml',
        test: /\.yml$/,
        exclude: /(node_modules|bower_components)/
      }
    ]
  },
  externals: {
    angular: 'angular',
    lodash: '_',
    MathJax: 'MathJax'
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
    new html({
      title: 'WBT-Framework',
      templateContent: jade.compileFile(__dirname+'/src/index.jade'),
      inject: 'head',
      base,
      prod,
      versions: {
        angular: '1.4.7',
        bootstrap: '3.3.5',
        fontAwesome: '4.4.0',
        lodash: '3.10.1',
        restangular: '1.5.1',
      }
    })
  ],
  devtool: 'source-map',
  devServer: {
    port: 9000,
    host: '0.0.0.0',
    proxy: {
      '*': {
        target: 'http://localhost:3000',
        rewrite: function(req){
          req.url = req.url.replace(base,'/');
        }
      }
    }
  }
};
if(prod){
  config.plugins.push(
    new webpack.optimize.DedupePlugin(),
    new compression()
  );
}
module.exports = config;
<|endoftext|>


<commit_before>const
	autoprefixer = require('autoprefixer'),
	cssnano = require('cssnano'),
	merge = require('webpack-merge'),
	path = require('path'),

	ExtractTextPlugin = require('extract-text-webpack-plugin')
;

module.exports = function(env, argv) {
	const
		COMMON = {
			mode: argv.mode || 'development',
			watch: !argv.mode,
			stats: {
				modules: false,
				children: false
			}
		},
		JAVASCRIPT = {
			entry: {'cruditor': './static/js/cruditor.js'},
			output: {
				filename: '[name].js',
				path: path.join(__dirname, 'cruditor', 'static', 'cruditor', 'js'),
				library: 'cruditor',
				libraryTarget: 'umd'
			},
			module: {
				rules: [{
					test: /\.svg$/,
					loader: 'html-loader',
					options: {minimize: false}
				}]
			}
			// resolve: {
			// 	modules: [
			// 		path.resolve(__dirname, 'static', 'js', 'src'),
			// 		path.resolve(__dirname, 'node_modules')
			// 	]
			// }
		},
		STYLESHEET = {
			entry: {'cruditor': './static/scss/cruditor.scss'},
			output: {
				filename: '[name].css',
				path: path.join(__dirname, 'cruditor', 'static', 'cruditor', 'css'),
			},
			module: {
				rules: [{
					test: /\.scss$/,
					use: ExtractTextPlugin.extract({use: [
						{loader: 'css-loader'},
						{loader: 'postcss-loader',
							options: {
								ident: 'postcss',
								plugins: [autoprefixer, cssnano]
							}
						},
						{loader: 'sass-loader'}
					]})
				}]
			},
			plugins: [
				new ExtractTextPlugin({
					filename: '[name].css',
					allChunks: true
				})
			],
			resolve: {
				alias: {
					bootstrap: path.join(__dirname, 'node_modules/bootstrap/scss')
				}
			}
		}
	;

	return [
		merge(COMMON, JAVASCRIPT),
		merge(COMMON, STYLESHEET)
	];
};
<commit_msg>Cleanup<commit_after>const
	autoprefixer = require('autoprefixer'),
	cssnano = require('cssnano'),
	merge = require('webpack-merge'),
	path = require('path'),

	ExtractTextPlugin = require('extract-text-webpack-plugin')
;

module.exports = function(env, argv) {
	const
		COMMON = {
			mode: argv.mode || 'development',
			watch: !argv.mode,
			stats: {
				modules: false,
				children: false
			}
		},
		JAVASCRIPT = {
			entry: {'cruditor': './static/js/cruditor.js'},
			output: {
				filename: '[name].js',
				path: path.join(__dirname, 'cruditor', 'static', 'cruditor', 'js'),
				library: 'cruditor',
				libraryTarget: 'umd'
			},
			module: {
				rules: [{
					test: /\.svg$/,
					loader: 'html-loader',
					options: {minimize: false}
				}]
			}
		},
		STYLESHEET = {
			entry: {'cruditor': './static/scss/cruditor.scss'},
			output: {
				filename: '[name].css',
				path: path.join(__dirname, 'cruditor', 'static', 'cruditor', 'css'),
			},
			module: {
				rules: [{
					test: /\.scss$/,
					use: ExtractTextPlugin.extract({use: [
						{loader: 'css-loader'},
						{loader: 'postcss-loader',
							options: {
								ident: 'postcss',
								plugins: [autoprefixer, cssnano]
							}
						},
						{loader: 'sass-loader'}
					]})
				}]
			},
			plugins: [
				new ExtractTextPlugin({
					filename: '[name].css',
					allChunks: true
				})
			],
			resolve: {
				alias: {
					bootstrap: path.join(__dirname, 'node_modules/bootstrap/scss')
				}
			}
		}
	;

	return [
		merge(COMMON, JAVASCRIPT),
		merge(COMMON, STYLESHEET)
	];
};
<|endoftext|>


<commit_before>import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import {defaultsDeep} from 'lodash/object';
import path from 'path';
import os from 'os';

const USER = os.hostname();

// Environment settings
let {
    DEV = 'true',
    DEV_SERVER_HOST = 'localhost',
    DEV_SERVER_PORT = 3000,
    ENTRY_FILE_PATH = './src',
    npm_package_name = 'your-project',
    OUTPUT_DIR = './dist',
    PAGE_TITLE = 'You project landing page',
    ANCHOR_CLASS = 'your-project',
    PUBLIC_PATH = '/',
    GENERATE_HTML = 'true',
    BABELIFIED_PATH = './src',
    MINIMIFY = 'false',
    LIBRARY_NAME = 'YourProject',
    SOURCE_MAPS = 'true',
    DEBUG = 'true',
    PACKAGE_JSON_PATH = './'
} = process.env;
// Parse json settings
DEV = JSON.parse(DEV);
GENERATE_HTML = JSON.parse(GENERATE_HTML);
MINIMIFY = JSON.parse(MINIMIFY);
SOURCE_MAPS = JSON.parse(SOURCE_MAPS);
DEBUG = JSON.parse(DEBUG);

/*************************************
********* Webpack config *************
**************************************/
const defaultConfig = definedVariables => ({
    entry: [
        path.resolve(process.cwd(), ENTRY_FILE_PATH)
    ].concat(DEV ? [
        `webpack-dev-server/client?http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`,
        'webpack/hot/only-dev-server'
    ] : []),
    output: {
        path: path.resolve(process.cwd(), OUTPUT_DIR),
        filename: `${npm_package_name}.js`,
        libraryTarget: 'umd',
        library: LIBRARY_NAME
    },
    devtool: SOURCE_MAPS ? 'source-map' : false,
    debug: DEBUG,
    stats: {
        colors: true,
        reasons: true
    },
    plugins: [
        new webpack.DefinePlugin({
            __DEV__: DEV ? 'true' : 'false',
            __ANCHOR_CLASS__: DEV ? JSON.stringify(ANCHOR_CLASS) : null,
            __PACKAGE_JSON_PATH__: JSON.stringify(PACKAGE_JSON_PATH),
            __USER__: JSON.stringify(USER),
            __PROJECT__: JSON.stringify(npm_package_name),
            ...definedVariables
        }),
        new webpack.optimize.DedupePlugin(),
        new ExtractTextPlugin(`${npm_package_name}.css`)
    ].concat(DEV ? [
        new webpack.HotModuleReplacementPlugin()
    ] : []).concat(GENERATE_HTML ? [
        new HtmlWebpackPlugin({
            inject: 'body',
            templateContent: `<html><head><meta charset="UTF-8"><title>${PAGE_TITLE}</title></head><body><div class="${ANCHOR_CLASS}"/></body></html>`
        })
    ] : []).concat(MINIMIFY ? [
        new webpack.optimize.UglifyJsPlugin({
            compressor: {
                'screw_ie8': true,
                warnings: false
            }
        })
    ] : []),
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx']
    },
    module: {
        preLoaders: [
            {
                test: /\.js$/,
                loader: 'source-map-loader'
            }
        ],
        loaders: [
            {
                test: /.jsx?$/,
                loader: DEV ? 'react-hot!babel' : 'babel',
                include: [
                    path.resolve(process.cwd(), BABELIFIED_PATH)
                ]
            },
            {
                test: /\.json$/,
                loaders: ['json']
            },
            {
                test: /\.scss$/,
                loader: ExtractTextPlugin.extract('style', 'css!autoprefixer-loader!sass')
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style-loader', 'css-loader', 'autoprefixer-loader')
            },
            {
                test: /\.png(\?.*)?$/,
                loader: 'url-loader',
                query: { mimetype: 'image/png' }
            },
            {
                test: /\.jpg(\?.*)?$/,
                loader: 'url-loader',
                query: { mimetype: 'image/jpg' }
            },
            {
                test: /\.gif(\?.*)?$/,
                loader: 'url-loader',
                query: { mimetype: 'image/gif' }
            },
            {
                test: /\.woff(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'application/font-woff'}
            },
            {
                test: /\.woff2(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'application/font-woff'}
            },
            {
                test: /\.ttf(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'application/octet-stream'}
            },
            {
                test: /\.eot(\?.*)?$/,
                loader: 'file'
            },
            {
                test: /\.svg(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'image/svg+xml'}
            }
        ]
    }
});

export const configBuilder = (customConf = {}, definedVariables = {}) => defaultsDeep(customConf, defaultConfig(definedVariables));
<commit_msg>[webpack] Add dev server host<commit_after>import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import {defaultsDeep} from 'lodash/object';
import path from 'path';
import os from 'os';

const USER = os.hostname();

// Environment settings
let {
    DEV = 'true',
    DEV_SERVER_HOST = 'localhost',
    DEV_SERVER_PORT = 3000,
    ENTRY_FILE_PATH = './src',
    npm_package_name = 'your-project',
    OUTPUT_DIR = './dist',
    PAGE_TITLE = 'You project landing page',
    ANCHOR_CLASS = 'your-project',
    PUBLIC_PATH = '/',
    GENERATE_HTML = 'true',
    BABELIFIED_PATH = './src',
    MINIMIFY = 'false',
    LIBRARY_NAME = 'YourProject',
    SOURCE_MAPS = 'true',
    DEBUG = 'true',
    PACKAGE_JSON_PATH = './'
} = process.env;
// Parse json settings
DEV = JSON.parse(DEV);
GENERATE_HTML = JSON.parse(GENERATE_HTML);
MINIMIFY = JSON.parse(MINIMIFY);
SOURCE_MAPS = JSON.parse(SOURCE_MAPS);
DEBUG = JSON.parse(DEBUG);

/*************************************
********* Webpack config *************
**************************************/
const defaultConfig = definedVariables => ({
    entry: [
        path.resolve(process.cwd(), ENTRY_FILE_PATH)
    ].concat(DEV ? [
        `webpack-dev-server/client?http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`,
        'webpack/hot/only-dev-server'
    ] : []),
    output: {
        path: path.resolve(process.cwd(), OUTPUT_DIR),
        publicPath: `http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`,
        filename: `${npm_package_name}.js`,
        libraryTarget: 'umd',
        library: LIBRARY_NAME
    },
    devtool: SOURCE_MAPS ? 'source-map' : false,
    debug: DEBUG,
    stats: {
        colors: true,
        reasons: true
    },
    plugins: [
        new webpack.DefinePlugin({
            __DEV__: DEV ? 'true' : 'false',
            __ANCHOR_CLASS__: DEV ? JSON.stringify(ANCHOR_CLASS) : null,
            __PACKAGE_JSON_PATH__: JSON.stringify(PACKAGE_JSON_PATH),
            __USER__: JSON.stringify(USER),
            __PROJECT__: JSON.stringify(npm_package_name),
            ...definedVariables
        }),
        new webpack.optimize.DedupePlugin(),
        new ExtractTextPlugin(`${npm_package_name}.css`)
    ].concat(DEV ? [
        new webpack.HotModuleReplacementPlugin()
    ] : []).concat(GENERATE_HTML ? [
        new HtmlWebpackPlugin({
            inject: 'body',
            templateContent: `<html><head><meta charset="UTF-8"><title>${PAGE_TITLE}</title></head><body><div class="${ANCHOR_CLASS}"/></body></html>`
        })
    ] : []).concat(MINIMIFY ? [
        new webpack.optimize.UglifyJsPlugin({
            compressor: {
                'screw_ie8': true,
                warnings: false
            }
        })
    ] : []),
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx']
    },
    module: {
        preLoaders: [
            {
                test: /\.js$/,
                loader: 'source-map-loader'
            }
        ],
        loaders: [
            {
                test: /.jsx?$/,
                loader: DEV ? 'react-hot!babel' : 'babel',
                include: [
                    path.resolve(process.cwd(), BABELIFIED_PATH)
                ]
            },
            {
                test: /\.json$/,
                loaders: ['json']
            },
            {
                test: /\.scss$/,
                loader: ExtractTextPlugin.extract('style', 'css!autoprefixer-loader!sass')
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style-loader', 'css-loader', 'autoprefixer-loader')
            },
            {
                test: /\.png(\?.*)?$/,
                loader: 'url-loader',
                query: { mimetype: 'image/png' }
            },
            {
                test: /\.jpg(\?.*)?$/,
                loader: 'url-loader',
                query: { mimetype: 'image/jpg' }
            },
            {
                test: /\.gif(\?.*)?$/,
                loader: 'url-loader',
                query: { mimetype: 'image/gif' }
            },
            {
                test: /\.woff(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'application/font-woff'}
            },
            {
                test: /\.woff2(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'application/font-woff'}
            },
            {
                test: /\.ttf(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'application/octet-stream'}
            },
            {
                test: /\.eot(\?.*)?$/,
                loader: 'file'
            },
            {
                test: /\.svg(\?.*)?$/,
                loader: 'url-loader',
                query: {limit: 50000, mimetype: 'image/svg+xml'}
            }
        ]
    }
});

export const configBuilder = (customConf = {}, definedVariables = {}) => defaultsDeep(customConf, defaultConfig(definedVariables));
<|endoftext|>


<commit_before>const
  webpack = require('webpack'),
  path = require('path'),
  version = require('./package.json').version;

module.exports = {
  mode: 'production',
  entry: './src/Kuzzle.js',
  output: {
    path: `${__dirname}/dist`,
    filename: 'kuzzle.js',
    library: 'Kuzzle',
    libraryTarget: 'umd'
  },
  watch: false,
  devtool: 'source-map',
  node: {
    console: false,
    global: false,
    process: false,
    Buffer: false,
    __filename: false,
    __dirname: false,
    setImmediate: false
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        query: {
          only: [/^src/],
          presets: [
            ['env', {
              debug: true,
              modules: false
            }]]
        }
      },
      {
        test: /\.js$/,
        loader: 'eslint-loader',
        include: path.resolve(__dirname, './src/'),
        exclude: /node_modules/
      }
    ]
  },
  plugins: [
    new webpack.IgnorePlugin(/^(http|min-req-promise|package|uws)$/),
    new webpack.DefinePlugin({
      SDKVERSION: JSON.stringify(version)
    }),
    new webpack.BannerPlugin('Kuzzle javascript SDK version ' + version),
    new webpack.optimize.OccurrenceOrderPlugin()
  ]
};
<commit_msg>[build] update webpack build config to fix raw web usage (#349)<commit_after>const
  webpack = require('webpack'),
  path = require('path'),
  version = require('./package.json').version;

module.exports = {
  mode: 'production',
  entry: './index.js',
  output: {
    path: `${__dirname}/dist`,
    filename: 'kuzzle.js',
    library: 'KuzzleSDK',
    libraryTarget: 'umd'
  },
  watch: false,
  devtool: 'source-map',
  node: {
    console: false,
    global: false,
    process: false,
    Buffer: false,
    __filename: false,
    __dirname: false,
    setImmediate: false
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        query: {
          only: [/^src/],
          presets: [
            ['env', {
              debug: true,
              modules: false
            }]]
        }
      },
      {
        test: /\.js$/,
        loader: 'eslint-loader',
        include: path.resolve(__dirname, './src/'),
        exclude: /node_modules/
      }
    ]
  },
  plugins: [
    new webpack.IgnorePlugin(/^(http|min-req-promise|package|uws)$/),
    new webpack.DefinePlugin({
      SDKVERSION: JSON.stringify(version),
      BUILT: true
    }),
    new webpack.BannerPlugin('Kuzzle javascript SDK version ' + version),
    new webpack.optimize.OccurrenceOrderPlugin()
  ]
};
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var packageJSON = require(path.join(__dirname, 'package.json'))

themes = Object.keys(packageJSON.devDependencies)
               .concat(Object.keys(packageJSON.dependencies))
               .filter((p) => (/(butter-theme-.*)/.test(p)))

module.exports = {
    devtool: 'eval',
    entry: [
        'webpack-dev-server/client?http://localhost:3000',
        'webpack/hot/only-dev-server',
        'webpack-material-design-icons',
        path.join(__dirname, 'index.js')
    ].concat(themes),
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js',
        publicPath: '/static/'
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin()
    ],
    resolve:{
        modules: [path.join(process.cwd(), 'node_modules')],
        alias: {
            node_modules: path.join(process.cwd(), 'node_modules'),
            "~": path.join(process.cwd(), 'node_modules'),
            btm_src: path.join (process.cwd(), 'src/index.js'),
            btm_test: path.join (process.cwd(), 'test/data.js'),
        }
    },
    module: {
        rules: [{
            test: /\.jsx?$/,
            loader: 'babel-loader',
            query: {
                plugins: [['react-transform', {
                    'transforms': [{
                        'transform': 'react-transform-hmr',
                        'imports': ['react'],
                        'locals': ['module']
                    }]
                }]],
                presets: ['es2015', 'stage-0', 'react']
            },
            include: [
                path.join(process.cwd(), 'src'),
                path.join(process.cwd(), 'test'),
                path.join(__dirname, 'index.js'),
                /node_modules\/(butter-.*)/
            ]
        }, {
            test: /\.(styl)$/,
            use: [
                'style-loader',
                'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
                {
                    loader: 'stylus-loader',
                    options: {
                        use: [require('nib')()],
                        import: ['~nib/index.styl', path.join(__dirname, 'styl/app.styl')]
                    },
                },
            ],
        },{
            test: /\.(css)$/,
            use: [
                'style-loader',
                'css-loader?importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
            ]
        },{
            test: /\.(jpg|png|svg|woff2?|eot|ttf).*$/,
            loader: "url-loader?limit=100000"
        }]
    }
};
<commit_msg>load base package.json not __dirname that points to the module<commit_after>var path = require('path');
var webpack = require('webpack');
var packageJSON = require(path.join(process.cwd(), 'package.json'))

themes = Object.keys(packageJSON.devDependencies)
               .concat(Object.keys(packageJSON.dependencies))
               .filter((p) => (/(butter-theme-.*)/.test(p)))

module.exports = {
    devtool: 'eval',
    entry: [
        'webpack-dev-server/client?http://localhost:3000',
        'webpack/hot/only-dev-server',
        'webpack-material-design-icons',
        path.join(__dirname, 'index.js')
    ].concat(themes),
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js',
        publicPath: '/static/'
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin()
    ],
    resolve:{
        modules: [path.join(process.cwd(), 'node_modules')],
        alias: {
            node_modules: path.join(process.cwd(), 'node_modules'),
            "~": path.join(process.cwd(), 'node_modules'),
            btm_src: path.join (process.cwd(), 'src/index.js'),
            btm_test: path.join (process.cwd(), 'test/data.js'),
        }
    },
    module: {
        rules: [{
            test: /\.jsx?$/,
            loader: 'babel-loader',
            query: {
                plugins: [['react-transform', {
                    'transforms': [{
                        'transform': 'react-transform-hmr',
                        'imports': ['react'],
                        'locals': ['module']
                    }]
                }]],
                presets: ['es2015', 'stage-0', 'react']
            },
            include: [
                path.join(process.cwd(), 'src'),
                path.join(process.cwd(), 'test'),
                path.join(__dirname, 'index.js'),
                /node_modules\/(butter-.*)/
            ]
        }, {
            test: /\.(styl)$/,
            use: [
                'style-loader',
                'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
                {
                    loader: 'stylus-loader',
                    options: {
                        use: [require('nib')()],
                        import: ['~nib/index.styl', path.join(__dirname, 'styl/app.styl')]
                    },
                },
            ],
        },{
            test: /\.(css)$/,
            use: [
                'style-loader',
                'css-loader?importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
            ]
        },{
            test: /\.(jpg|png|svg|woff2?|eot|ttf).*$/,
            loader: "url-loader?limit=100000"
        }]
    }
};
<|endoftext|>


<commit_before>import webpack from "webpack";
import config from './gulp/config';

var webpackConfig = {
    output: {
        filename: "[name].js",
        sourceMapFilename: 'maps/[name].map',
        jsonpFunction: 'f'
    },
    devtool: '#source-map',
    resolve: {
        modulesDirectories: [
            'bower_components',
            'node_modules',
            'src',
            'lib'
        ]
    },
    module: {
        preLoaders: [
            { test: /\.js$/, exclude: /node_modules|bower_components/, loader: 'eslint-loader' }
        ],
        loaders: [
            { test: /\.html$/, loader: 'html-loader' },
            { test: /test\/.*?Spec\.js$/, loader: 'webpack-espower-loader' },
            { test: /\.js/, exclude: /node_modules|bower_components/, loaders: ['babel-loader'] }
        ],
        noParse: ['node_modules','bower_components']
    },
    plugins: [
        new webpack.DefinePlugin({
            IS_PRODUCTION: config.IS_PRODUCTION
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: true
            }
        }),
        //new webpack.optimize.CommonsChunkPlugin('app','app.js'),
        new webpack.optimize.AggressiveMergingPlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.DedupePlugin()
    ],
    eslint: {
        configFile: '.eslintrc',
        failOnError: true
    }
};

export default webpackConfig;<commit_msg>fix(webpack): noParseの範囲が広すぎのを修正。Uglifyのwarningsオプションをfalseに変更<commit_after>import webpack from "webpack";
import config from './gulp/config';

var webpackConfig = {
    output: {
        filename: "[name].js",
        sourceMapFilename: 'maps/[name].map',
        jsonpFunction: 'f'
    },
    devtool: '#source-map',
    resolve: {
        modulesDirectories: [
            'bower_components',
            'node_modules',
            'src',
            'lib'
        ]
    },
    module: {
        preLoaders: [
            { test: /\.js$/, exclude: /node_modules|bower_components/, loader: 'eslint-loader' }
        ],
        loaders: [
            { test: /\.html$/, loader: 'html-loader' },
            { test: /test\/.*?Spec\.js$/, loader: 'webpack-espower-loader' },
            { test: /\.js/, exclude: /node_modules|bower_components/, loaders: ['babel-loader'] }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            IS_PRODUCTION: config.IS_PRODUCTION
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        }),
        //new webpack.optimize.CommonsChunkPlugin('app','app.js'),
        new webpack.optimize.AggressiveMergingPlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.DedupePlugin()
    ],
    eslint: {
        configFile: '.eslintrc',
        failOnError: true
    }
};

export default webpackConfig;<|endoftext|>


<commit_before>process.traceDeprecation = true;
const path = require("path");
const patternslib_config = require("@patternslib/patternslib/webpack/webpack.config.js");

module.exports = async (env, argv) => {
    let config = {
        entry: {
            bundle: path.resolve(__dirname, "bundle-config.js"),
        },
    };

    config = patternslib_config(env, argv, config);
    config.output.path = path.resolve(__dirname, "dist/");

    return config;
};
<commit_msg>maint(webpack): Configure devServer static directory.<commit_after>process.traceDeprecation = true;
const path = require("path");
const patternslib_config = require("@patternslib/patternslib/webpack/webpack.config.js");

module.exports = async (env, argv) => {
    let config = {
        entry: {
            bundle: path.resolve(__dirname, "bundle-config.js"),
        },
    };

    config = patternslib_config(env, argv, config);
    config.output.path = path.resolve(__dirname, "dist/");

    if (process.env.NODE_ENV === "development") {
        config.devServer.static.directory = __dirname;
    }

    return config;
};
<|endoftext|>


<commit_before>'use strict';

const path = require('path');
const loaders = require('./webpack/loaders');
const plugins = require('./webpack/plugins');
const ENV = process.env.npm_lifecycle_event;
const JiT = ENV === 'build:jit';
if (JiT) {
  console.log('AoT: false');
}
module.exports = {
  entry: {
    app: './src/main.ts',
    // and vendor files separate
    vendor: [
      '@angular/core',
      '@angular/router',
      '@angular/platform-browser',
    ],
  },

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].[hash]-[id].js',
    publicPath: '/',
    sourceMapFilename: '[name].[hash]-[id].js.map',
    chunkFilename: '[name].chunk.[hash]-[id].js',
  },

  devtool: process.env.NODE_ENV === 'production' ?
    'source-map' :
    'inline-source-map',

  resolve: {
    extensions: ['.webpack.js', '.web.js', '.ts', '.js'],
  },

  plugins: plugins,

  devServer: {
    historyApiFallback: { index: '/' },
    proxy: {},
  },

  module: {
    rules: [
      loaders.angular,
      loaders.tslint,
      loaders.ts_JiT,
      loaders.html,
      loaders.css,
      loaders.svg,
      loaders.eot,
      loaders.woff,
      loaders.woff2,
      loaders.ttf,
    ],
  },
};
<commit_msg>Use [chunkhash] in production & dont use hash in dev (#182)<commit_after>'use strict';

const path = require('path');
const loaders = require('./webpack/loaders');
const plugins = require('./webpack/plugins');
const ENV = process.env.npm_lifecycle_event;
const JiT = ENV === 'build:jit';
if (JiT) {
  console.log('AoT: false');
}
module.exports = {
  entry: {
    app: './src/main.ts',
    // and vendor files separate
    vendor: [
      '@angular/core',
      '@angular/router',
      '@angular/platform-browser',
    ],
  },

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: process.env.NODE_ENV === 'production' ?
      '[name].[chunkhash].js' : '[name].js',
    publicPath: '/',
    sourceMapFilename: process.env.NODE_ENV === 'production' ?
      '[name].[chunkhash].js.map' : '[name].js.map',
    chunkFilename: process.env.NODE_ENV === 'production' ?
      '[name].chunk.[chunkhash].js' : '[name].js',
  },

  devtool: process.env.NODE_ENV === 'production' ?
    'source-map' :
    'inline-source-map',

  resolve: {
    extensions: ['.webpack.js', '.web.js', '.ts', '.js'],
  },

  plugins: plugins,

  devServer: {
    historyApiFallback: { index: '/' },
    proxy: {},
  },

  module: {
    rules: [
      loaders.angular,
      loaders.tslint,
      loaders.ts_JiT,
      loaders.html,
      loaders.css,
      loaders.svg,
      loaders.eot,
      loaders.woff,
      loaders.woff2,
      loaders.ttf,
    ],
  },
};
<|endoftext|>