'use strict'
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const { VueLoaderPlugin } = require('vue-loader')
const utils = require('./utils')
module.exports = {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue': 'vue/dist/vue.js',
'assets': utils.resolve('assets'),
'pages': utils.resolve('src/pages'),
'static': utils.resolve('static'),
'components': utils.resolve('src/components'),
'api': utils.resolve('src/api')
}
},
module: {
rules: [
{
test: /\.(js|vue)$/,
use: 'eslint-loader',
enforce: 'pre'
}, {
test: /\.vue$/,
use: 'vue-loader'
}, {
test: /\.js$/,
use: {
loader: 'babel-loader',
}
}, {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
}
}, {
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
}
}, {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
alwaysWriteToDisk: true
}),
new HtmlWebpackHarddiskPlugin(),
new VueLoaderPlugin(),
new CopyWebpackPlugin([
{
from: utils.resolve('static/img'),
to: utils.resolve('dist/static/img'),
toType: 'dir'
}
])
]
}