admin-fe/build/webpack.base.conf.js

108 lines
2.7 KiB
JavaScript
Raw Normal View History

'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
2018-08-15 07:33:34 +00:00
const { VueLoaderPlugin } = require('vue-loader')
const vueLoaderConfig = require('./vue-loader.conf')
2017-04-18 07:09:13 +00:00
2018-08-15 07:33:34 +00:00
function resolve(dir) {
2017-08-07 08:11:10 +00:00
return path.join(__dirname, '..', dir)
2017-04-18 07:09:13 +00:00
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
2017-04-18 07:09:13 +00:00
module.exports = {
context: path.resolve(__dirname, '../'),
2017-08-07 08:11:10 +00:00
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
2018-08-15 07:33:34 +00:00
publicPath:
process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
2017-08-07 08:11:10 +00:00
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
2018-08-15 07:33:34 +00:00
'@': resolve('src')
2017-08-07 08:11:10 +00:00
}
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
2017-08-07 08:11:10 +00:00
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader?cacheDirectory',
2018-08-15 07:33:34 +00:00
include: [
resolve('src'),
resolve('test'),
resolve('node_modules/webpack-dev-server/client')
]
2017-08-07 08:11:10 +00:00
},
2017-08-29 08:28:28 +00:00
{
test: /\.svg$/,
loader: 'svg-sprite-loader',
include: [resolve('src/icons')],
options: {
symbolId: 'icon-[name]'
}
},
2017-08-07 08:11:10 +00:00
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
2017-08-29 08:28:28 +00:00
exclude: [resolve('src/icons')],
2017-09-08 07:37:13 +00:00
options: {
2017-08-07 08:11:10 +00:00
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
2017-04-18 07:09:13 +00:00
}
2017-08-07 08:11:10 +00:00
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
2017-08-07 08:11:10 +00:00
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
2017-09-08 07:37:13 +00:00
options: {
2017-08-07 08:11:10 +00:00
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
2018-08-15 07:33:34 +00:00
plugins: [new VueLoaderPlugin()],
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
2017-04-18 07:09:13 +00:00
}