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

93 lines
2.6 KiB
JavaScript
Raw Normal View History

2017-08-07 08:11:10 +00:00
var path = require('path')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
2017-04-18 07:09:13 +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
}
module.exports = {
2017-08-07 08:11:10 +00:00
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV !== 'development' ? config.build.assetsPublicPath : config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components'),
'views': path.resolve(__dirname, '../src/views'),
'styles': path.resolve(__dirname, '../src/styles'),
'api': path.resolve(__dirname, '../src/api'),
'utils': path.resolve(__dirname, '../src/utils'),
'store': path.resolve(__dirname, '../src/store'),
'router': path.resolve(__dirname, '../src/router'),
'mock': path.resolve(__dirname, '../src/mock'),
'vendor': path.resolve(__dirname, '../src/vendor'),
'static': path.resolve(__dirname, '../static')
}
},
module: {
rules: [
2017-08-22 07:43:34 +00:00
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: "pre",
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter')
}
},
2017-08-07 08:11:10 +00:00
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader?cacheDirectory',
include: [resolve('src'), resolve('test')]
},
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: /\.(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]')
}
}
]
},
//注入全局mixin
// sassResources: path.join(__dirname, '../src/styles/mixin.scss'),
// sassLoader: {
// data: path.join(__dirname, '../src/styles/index.scss')
// },
2017-04-18 07:09:13 +00:00
}
2017-08-07 08:11:10 +00:00