2020-04-03 16:34:17 +08:00
|
|
|
const path = require('path')
|
|
|
|
|
const webpack = require('webpack')
|
|
|
|
|
const { VueLoaderPlugin } = require('vue-loader')
|
|
|
|
|
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin')
|
|
|
|
|
const notifier = require('node-notifier')
|
|
|
|
|
|
|
|
|
|
function resolve (dir) {
|
2020-10-06 17:03:32 +08:00
|
|
|
return path.join(process.cwd(), dir)
|
2020-04-03 16:34:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
mode: 'production',
|
|
|
|
|
entry: './src/main.js',
|
|
|
|
|
output: {
|
2020-10-06 17:03:32 +08:00
|
|
|
path: resolve('./lib'),
|
2020-04-03 16:34:17 +08:00
|
|
|
publicPath: '/lib/',
|
|
|
|
|
filename: 'hoc-el-affix.js',
|
|
|
|
|
libraryTarget: 'umd'
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
enforce: 'pre',
|
|
|
|
|
test: /\.(vue|js)(\?.*)?$/,
|
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
|
include: resolve('src'),
|
|
|
|
|
options: {
|
|
|
|
|
fix: true,
|
|
|
|
|
failOnError: true,
|
|
|
|
|
useEslintrc: true,
|
|
|
|
|
configFile: resolve('.eslintrc.js'),
|
|
|
|
|
formatter: require('eslint-friendly-formatter')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
use: [
|
|
|
|
|
'vue-style-loader',
|
|
|
|
|
'css-loader'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.scss$/,
|
|
|
|
|
use: [
|
|
|
|
|
'vue-style-loader',
|
|
|
|
|
'css-loader',
|
|
|
|
|
'sass-loader'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.sass$/,
|
|
|
|
|
use: [
|
|
|
|
|
'vue-style-loader',
|
|
|
|
|
'css-loader',
|
|
|
|
|
'sass-loader?indentedSyntax'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.vue$/,
|
|
|
|
|
use: {
|
|
|
|
|
loader: 'vue-loader'
|
|
|
|
|
},
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
include: resolve('src')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
use: {
|
|
|
|
|
loader: 'babel-loader',
|
|
|
|
|
options: {
|
2020-10-06 17:03:32 +08:00
|
|
|
extends: resolve('babel.config.js')
|
2020-04-03 16:34:17 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(png|jpg|gif|svg)$/,
|
|
|
|
|
loader: 'file-loader',
|
|
|
|
|
options: {
|
|
|
|
|
name: '[name].[ext]?[hash]'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
vue$: 'vue/dist/vue.esm.js',
|
|
|
|
|
'@': resolve('src')
|
|
|
|
|
},
|
|
|
|
|
extensions: ['*', '.js', '.vue', '.json']
|
|
|
|
|
},
|
|
|
|
|
devServer: {
|
|
|
|
|
historyApiFallback: true,
|
|
|
|
|
disableHostCheck: true,
|
|
|
|
|
inline: false,
|
|
|
|
|
overlay: true,
|
|
|
|
|
quiet: true
|
|
|
|
|
},
|
|
|
|
|
performance: {
|
|
|
|
|
hints: false
|
|
|
|
|
},
|
|
|
|
|
devtool: 'source-map',
|
|
|
|
|
plugins: [
|
|
|
|
|
new VueLoaderPlugin(),
|
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
|
minimize: true
|
|
|
|
|
}),
|
|
|
|
|
new FriendlyErrorsWebpackPlugin({
|
|
|
|
|
clearConsole: false,
|
|
|
|
|
onErrors: (severity, errors) => {
|
|
|
|
|
if (severity !== 'error') {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const error = errors[0]
|
|
|
|
|
notifier.notify({
|
|
|
|
|
title: 'Webpack error',
|
|
|
|
|
message: `${severity}: ${error.name}`,
|
|
|
|
|
subtitle: error.file || ''
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
}
|