I am using webpack to package a google chrome extension, I want to keep the folder structure in the dist folder. for example, I want to package all popup resource in the dist/popup/*
, this is my config right now:
const path = require('path');
const webpack = require( 'webpack' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin');
const HtmlWebpackPlugin = require( 'html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
entry : {
popup : './src/popup/'
} ,
resolve: {
alias: {
// https://stackoverflow.com/questions/50805384/module-not-found-error-cant-resolve-vue-path-not-correct
vue: 'vue/dist/vue.esm-bundler.js'
},
},
output : {
path : path.resolve(__dirname, '../../bundle') ,
filename : '[path]/[name].js'
},
module : {
rules : [
{
test : /.js$/ ,
exclude : [ /node_modules(?!(/|\?\)(translation.js|selection-widget|connect.io|chrome-env)1)/ ] ,
loader : 'babel-loader'
} ,
{
test: /.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test : /.(scss)$/ ,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}
]
},
plugins : [
new CopyPlugin({
patterns: [
{ from: "src/manifest.json", to: "manifest.json" },
{ from: "src/resource/image", to: "resource/image" },
],
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
new HtmlWebpackPlugin({
filename: 'popup.html',
template: 'src/popup/index.html'
}),
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: false,
__VUE_PROD_DEVTOOLS__: false,
}),
]
};
I have tried to tweak the output filename like this:
filename : '[path]/[name].js'
seems did not work. I am searching from google and did not found any suggestion. Is it possible to do like this? or different entry with different dist folder.