Export properly

This commit is contained in:
Josh Johnson 2017-11-15 06:51:53 +00:00
parent 7c1a18895e
commit e8d8f8662e
6 changed files with 2581 additions and 2284 deletions

View file

@ -1,13 +1,13 @@
let webpack = require('webpack');
let WebpackDevServer = require('webpack-dev-server');
let config = require('./webpack.config.dev');
let opn = require('opn');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config.dev');
const opn = require('opn');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
historyApiFallback: true,
quiet: true, // lets WebpackDashboard do its thing
}).listen(3001, 'localhost', (err, result) => {
}).listen(3001, 'localhost', (err) => {
if (err) console.log(err);
opn('http://localhost:3001');
console.log('Listening at localhost:3001');

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -32,7 +32,7 @@ import './lib/polyfills';
/**
* Choices
*/
export default class Choices {
class Choices {
constructor(element = '[data-choice]', userConfig = {}) {
// If there are multiple elements, create a new instance
// for each element besides the first one (as that already has an instance)
@ -2405,3 +2405,6 @@ export default class Choices {
}
Choices.userDefaults = {};
// We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929
module.exports = Choices;

View file

@ -1,8 +1,9 @@
const path = require('path');
const pkg = require('./package.json');
const webpack = require('webpack');
const wrapperPlugin = require('wrapper-webpack-plugin');
const banner = `/*! ${ pkg.name } v${ pkg.version } | (c) ${ new Date().getFullYear() } ${ pkg.author } | ${ pkg.homepage } */ \n`;
const WrapperPlugin = require('wrapper-webpack-plugin');
const banner = `/*! ${pkg.name} v${pkg.version} | (c) ${new Date().getFullYear()} ${pkg.author} | ${pkg.homepage} */ \n`;
module.exports = (env) => {
const minimize = !!(env && env.minimize);
@ -10,7 +11,7 @@ module.exports = (env) => {
const config = {
devtool: minimize ? false : 'cheap-module-source-map',
entry: [
'./src/scripts/src/choices'
'./src/scripts/src/choices',
],
output: {
path: path.join(__dirname, '/src/scripts/dist'),
@ -18,30 +19,44 @@ module.exports = (env) => {
publicPath: '/src/scripts/dist/',
library: 'Choices',
libraryTarget: 'umd',
auxiliaryComment: {
root: 'Window',
commonjs: 'CommonJS',
commonjs2: 'CommonJS2',
amd: 'AMD',
},
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production'),
}
NODE_ENV: JSON.stringify('production'),
},
}),
new wrapperPlugin({
new WrapperPlugin({
header: banner,
}),
],
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
include: path.join(__dirname, 'src/scripts/src'),
options: {
babelrc: false,
presets: [['es2015', { modules: false }], 'stage-2'],
rules: [
{
enforce: 'pre',
test: /\.js?$/,
include: path.join(__dirname, 'src/scripts/src'),
exclude: /(node_modules|bower_components)/,
loader: 'eslint-loader',
query: {
configFile: '.eslintrc',
},
},
}],
{
test: /\.js?$/,
include: path.join(__dirname, 'src/scripts/src'),
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
},
],
},
};
@ -50,12 +65,12 @@ module.exports = (env) => {
sourceMap: false,
mangle: true,
output: {
comments: false
comments: false,
},
compress: {
warnings: false,
screw_ie8: true
}
screw_ie8: true,
},
}));
}