const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const projectName = 'ywbb'
module.exports = {
	entry: {
		singleSpaEntry: ['src/singleSpaEntry.js']
	},
	output: {
		filename: '[name].js',
		path: path.resolve(__dirname, 'ywbb'),
		libraryTarget: 'umd',
		library: 'ywbb'
	},
	module: {
		rules: [
			{
				test: /\.vue$/,
				loader: 'vue-loader',
				options: {
					loaders: {
						js: 'babel-loader'
					}
				}
			},
			{
				test: /\.js$/,
				loader: 'babel-loader',
				exclude: /node_modules/,
				include: path.join(__dirname, './src')
			},
			{
				test: /\.(png|jpg|gif|svg)$/,
				loader: 'file-loader',
				options: {
					name: '[name].[ext]?[hash]',
					publicPath: `../${projectName}`
				}
			},
			{
				test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
				loader: 'url-loader',
				options: {
					limit: 100000,
					name: 'fonts/[name].[hash:7].[ext]',
					publicPath: `../${projectName}`
				}
			},
			{
				test: /\.css$/,
				use: ['vue-style-loader', 'css-loader']
			},
			{
				test: /\.scss$/,
				loaders: ['vue-style-loader', 'css-loader', 'sass-loader']
			}
		]
	},
	resolve: {
		alias: {
			vue$: 'vue/dist/vue.esm.js',
			'@': path.join(__dirname, './src')
		},
		extensions: ['.js', '.vue'],
		modules: [__dirname, 'node_modules']
	},
	mode: 'development',
	devtool: 'none',
	externals: {
	    './cptable': 'var cptable'
	},
	plugins: [new VueLoaderPlugin()],
	node: {
	    fs: 'empty'
	},
}
