I am trying to add vue to my existing webpack app (based on this simple demo). I only want to load vue and SFC files in a specific entrypoint, but I am getting this error during build:
ERROR in chunk testview [entry]
style.css
Conflict: Multiple chunks emit assets to the same filename style.css (chunks app and testview)
The file I'm trying to load is ./js/components/main-content.vue
The contents of the entrypoint in question, ./js/views/TestView.js file is:
import Vue from "vue";
import MainContent from "../components/main-content";
let MainComponent = Vue.extend(MainContent);
new MainComponent().$mount("#mainContent");
It's worth noting that if I include the above in my app.js, it works fine. The error doesn't appear, and vue (and SFC) loads properly in the browser.
An abbreviated version of my webpack.config.js is:
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (env, argv) => {
return {
entry: {
app: ["./src/polyfills.js", "./src/scss/styles.scss", "./src/app.js"],
...
testview: "./src/js/views/TestView.js"
},
output: {
path: assets,
filename: "[name].[hash].js",
publicPath: "/static/"
},
resolve: {
modules: ["node_modules", "src"],
alias: {
vue$: "vue/dist/vue.esm.js"
},
extensions: ["*", ".js", ".vue"]
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
...
}
]
},
{
test: /\.s?[ac]ss$/,
use: [
{
loader: "vue-style-loader"
},
{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader"
}
...
]
},
{
test: /\.vue$/,
loader: "vue-loader"
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: "commons",
chunks: "initial",
minChunks: 2,
minSize: 0
}
}
},
occurrenceOrder: true
},
plugins: [
new HtmlWebpackPlugin({
hash: true,
inject: false,
template: "./src/jinja-templates/base.html.j2",
filename: `${templates}/base.html.j2`,
environment: environment,
development: ifNotProduction()
}),
new MiniCssExtractPlugin({
filename: devMode ? "style.css" : "style.[hash].css"
}),
...
new VueLoaderPlugin()
]
};
};