var path = require('path')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
var webpack = require('webpack')
var MpvuePlugin = require('webpack-mpvue-asset-plugin')
var glob = require('glob')
return path.join(__dirname, '..', dir)
function getEntry (rootSrc, pattern) {
var files = glob.sync(path.resolve(rootSrc, pattern))
return files.reduce((res, file) => {
var info = path.parse(file)
var key = info.dir.slice(rootSrc.length + 1) + '/' + info.name
res[key] = path.resolve(file)
const appEntry = { app: resolve('./src/main.js') }
const pagesEntry = getEntry(resolve('./src'), 'pages/**/main.js')
const entry = Object.assign({}, appEntry, pagesEntry)
// 如果要自定义生成的 dist 目录里面的文件路径,
// 可以将 entry 写成 {'toPath': 'fromPath'} 的形式,
// toPath 为相对于 dist 的路径, 例:index/demo,则生成的文件地址为 dist/index/demo.js
target: require('mpvue-webpack-target'),
path: config.build.assetsRoot,
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
extensions: ['.js', '.vue', '.json'],
'vue': resolve('src/utils/vue'),
'flyio': 'flyio/dist/npm/wx',
'wx': resolve('src/utils/wx')
include: [resolve('src'), resolve('test')],
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
name: utils.assetsPath('img/[name].[ext]')
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
name: utils.assetsPath('media/[name]].[ext]')
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
name: utils.assetsPath('fonts/[name].[ext]')
new webpack.ProvidePlugin({
GioPage: [resolve('src/utils/gio-minp.js'), 'GioPage'],
GioApp: [resolve('src/utils/gio-minp.js'), 'GioApp'],
GioComponent: [resolve('src/utils/gio-minp.js'), 'GioComponent']