我需要实现如下所示的webpack构建结构:
var webpack = require( 'webpack' );
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
'basic': './modules/track/themes/basic/front/index.js',
'basicUpgrade': './modules/track/themes/basicUpgrade/front/index.js',
},
output: {
filename: '[name]/assets/js/index.js',
path: path.resolve(__dirname, 'modules/track/themes')
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
exclude: path.resolve(__dirname, 'node_modules')
},
]
},
resolve: {
extensions: ['.js']
},
plugins: [
new CleanWebpackPlugin()
],
};
但是问题是我无法在路径内粘贴[名称],结果我从主题目录中删除了所有内容,并且构建无法按预期工作。
相反,我希望该条目是来自以下位置的所有script.js文件:
modules/track/themes/basic/front/index.js
modules/track/themes/basicUpgrade/front/index.js and etc.
,然后将所有这些文件构建到
modules/track/themes/basicUpgrade/assets/js/index.js
modules/track/themes/basicUpgrade/assets/js/index.js