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'); const webpack = require('webpack');
let WebpackDevServer = require('webpack-dev-server'); const WebpackDevServer = require('webpack-dev-server');
let config = require('./webpack.config.dev'); const config = require('./webpack.config.dev');
let opn = require('opn'); const opn = require('opn');
new WebpackDevServer(webpack(config), { new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath, publicPath: config.output.publicPath,
historyApiFallback: true, historyApiFallback: true,
quiet: true, // lets WebpackDashboard do its thing quiet: true, // lets WebpackDashboard do its thing
}).listen(3001, 'localhost', (err, result) => { }).listen(3001, 'localhost', (err) => {
if (err) console.log(err); if (err) console.log(err);
opn('http://localhost:3001'); opn('http://localhost:3001');
console.log('Listening at 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 * Choices
*/ */
export default class Choices { class Choices {
constructor(element = '[data-choice]', userConfig = {}) { constructor(element = '[data-choice]', userConfig = {}) {
// If there are multiple elements, create a new instance // If there are multiple elements, create a new instance
// for each element besides the first one (as that already has an instance) // for each element besides the first one (as that already has an instance)
@ -2405,3 +2405,6 @@ export default class Choices {
} }
Choices.userDefaults = {}; 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 path = require('path');
const pkg = require('./package.json'); const pkg = require('./package.json');
const webpack = require('webpack'); const webpack = require('webpack');
const wrapperPlugin = require('wrapper-webpack-plugin'); const WrapperPlugin = require('wrapper-webpack-plugin');
const banner = `/*! ${ pkg.name } v${ pkg.version } | (c) ${ new Date().getFullYear() } ${ pkg.author } | ${ pkg.homepage } */ \n`;
const banner = `/*! ${pkg.name} v${pkg.version} | (c) ${new Date().getFullYear()} ${pkg.author} | ${pkg.homepage} */ \n`;
module.exports = (env) => { module.exports = (env) => {
const minimize = !!(env && env.minimize); const minimize = !!(env && env.minimize);
@ -10,7 +11,7 @@ module.exports = (env) => {
const config = { const config = {
devtool: minimize ? false : 'cheap-module-source-map', devtool: minimize ? false : 'cheap-module-source-map',
entry: [ entry: [
'./src/scripts/src/choices' './src/scripts/src/choices',
], ],
output: { output: {
path: path.join(__dirname, '/src/scripts/dist'), path: path.join(__dirname, '/src/scripts/dist'),
@ -18,30 +19,44 @@ module.exports = (env) => {
publicPath: '/src/scripts/dist/', publicPath: '/src/scripts/dist/',
library: 'Choices', library: 'Choices',
libraryTarget: 'umd', libraryTarget: 'umd',
auxiliaryComment: {
root: 'Window',
commonjs: 'CommonJS',
commonjs2: 'CommonJS2',
amd: 'AMD',
},
}, },
plugins: [ plugins: [
new webpack.optimize.ModuleConcatenationPlugin(), new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
// This has effect on the react lib size // This has effect on the react lib size
'NODE_ENV': JSON.stringify('production'), NODE_ENV: JSON.stringify('production'),
} },
}), }),
new wrapperPlugin({ new WrapperPlugin({
header: banner, header: banner,
}), }),
], ],
module: { module: {
rules: [{ rules: [
test: /\.js$/, {
exclude: /(node_modules|bower_components)/, enforce: 'pre',
loader: 'babel-loader', test: /\.js?$/,
include: path.join(__dirname, 'src/scripts/src'), include: path.join(__dirname, 'src/scripts/src'),
options: { exclude: /(node_modules|bower_components)/,
babelrc: false, loader: 'eslint-loader',
presets: [['es2015', { modules: false }], 'stage-2'], 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, sourceMap: false,
mangle: true, mangle: true,
output: { output: {
comments: false comments: false,
}, },
compress: { compress: {
warnings: false, warnings: false,
screw_ie8: true screw_ie8: true,
} },
})); }));
} }