Skip to content

Commit 8ea63f2

Browse files
committed
fix: resolve vue as external library in prod build
The webpack production build previously bundled vue, resulting in any library consumer having two instances of vue. This change declares the `vue` library as "external" in webpack, skipping the bundeling.
1 parent e486fe7 commit 8ea63f2

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

dev/dev-server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ app.use(webpackMiddleware(webpack(
1414
publicPath: '/dist/'
1515
}));
1616

17+
app.use('/esm', express.static(path.resolve(__dirname, 'esm')));
18+
app.use('/dist-static', express.static(path.resolve(__dirname, '../dist')));
19+
1720
app.get('/', function (req, res) {
1821
res.render('index');
1922
});

dev/esm/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
8+
<link rel="stylesheet" href="/dist-static/main.css">
9+
<title>vue-step-progress</title>
10+
</head>
11+
<body>
12+
<div id="app">
13+
<div class="row">
14+
<step-progress :steps="steps" :current-step="currentStep" icon-class="fa fa-check" :activeColor="activeColor" :passiveColor="passiveColor" :lineThickness="lineThickness" :activeThickness="activeThickness" :passiveThickness="passiveThickness"></step-progress>
15+
</div>
16+
<div class="buttons"><button @click="currentStep--">&lt;</button><button @click="currentStep++">></button><button @click="activeColor = &quot;purple&quot; ">Set active color to purple</button><button @click="passiveColor = &quot;pink&quot; ">Set passive color to pink</button>
17+
<div style="margin-top:10px"><label> Thickness:</label><input type="text" v-model="lineThickness" /></div>
18+
<div style="margin-top:10px"><label> Active Step Thickness</label><input type="text" v-model="activeThickness" /></div>
19+
<div style="margin-top:10px"><label> Passive Step Thickness</label><input type="text" v-model="passiveThickness" /></div>
20+
</div>
21+
</div>
22+
<script src="https://unpkg.com/vue@3"></script>
23+
<script src="/dist-static/vue-step-progress.min.js"></script>
24+
<script src="main.js"></script>
25+
</body>
26+
</html>

dev/esm/main.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { createApp } = Vue
2+
3+
createApp({
4+
name: 'App',
5+
components: {
6+
'step-progress': StepProgress.default
7+
},
8+
data() {
9+
return {
10+
steps: [
11+
'Learn Vue',
12+
'Open Source',
13+
'???',
14+
'Profit'
15+
],
16+
currentStep: 0,
17+
activeColor: 'red',
18+
passiveColor: 'gray',
19+
lineThickness: 12,
20+
activeThickness: 5,
21+
passiveThickness: 5
22+
};
23+
}
24+
}).mount('#app')

webpack.prod.config.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ module.exports = {
6464
}
6565
],
6666
},
67-
resolve: {
68-
modules: [
69-
'node_modules',
70-
'vue'
71-
]
67+
externals: {
68+
'vue': 'Vue',
7269
},
7370
plugins: [
7471
new VueLoaderPlugin(),

0 commit comments

Comments
 (0)