|
@@ -1,51 +1,32 @@
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
|
-const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
|
+const copyToApps = require('./copyPlugins')
|
|
|
+const htmlPluginsArr = require('./htmlPlugins')
|
|
|
const path = require('path')
|
|
|
-let fs = require('fs')
|
|
|
-const adminPath = 'admins'
|
|
|
+const entrys = require('./jsEntry')
|
|
|
function resolve (dir) {
|
|
|
return path.resolve(__dirname, '../', dir)
|
|
|
}
|
|
|
-
|
|
|
-// 获取 admins 目录下的后台管理系统文件名并指定公共文件目录命名
|
|
|
-const files = fs.readdirSync(resolve(adminPath))
|
|
|
-function copyToApps(dir) {
|
|
|
- let r = []
|
|
|
-
|
|
|
- files.map(app => {
|
|
|
- r.push({
|
|
|
- from: resolve(dir),
|
|
|
- to: resolve(`${adminPath}/${app}/${dir}`)
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- return r
|
|
|
-}
|
|
|
-let htmlPluginsArr = []
|
|
|
-files.map(app => {
|
|
|
- const config = require(`./../admins/${app}/config/config.js`)
|
|
|
- htmlPluginsArr.push(new HtmlWebpackPlugin({
|
|
|
- filename: `./../admins/${app}/index.html`,
|
|
|
- template: 'index.html',
|
|
|
- title: config.title,
|
|
|
- navTitle: config.navTitle
|
|
|
- }))
|
|
|
-})
|
|
|
+console.log(entrys)
|
|
|
|
|
|
module.exports = {
|
|
|
mode: 'development',
|
|
|
watch: true,
|
|
|
- entry: resolve('index.js'),
|
|
|
+ entry: entrys,
|
|
|
|
|
|
output: {
|
|
|
- path: resolve('.tmp'),
|
|
|
- filename: 'bundle.js'
|
|
|
+ path: resolve('admins/zl-mall-backstage/dist/js'),
|
|
|
+ filename: '[name].js'
|
|
|
},
|
|
|
devServer: {
|
|
|
hot: true,
|
|
|
port: 9000,
|
|
|
contentBase: false
|
|
|
},
|
|
|
+ module: {
|
|
|
+ rules: [
|
|
|
+ { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
|
|
|
+ ]
|
|
|
+ },
|
|
|
plugins: [
|
|
|
new CopyWebpackPlugin([
|
|
|
...copyToApps('statics'),
|