Skip to content

Commit 149ae7f

Browse files
author
Joel Denning
authored
Adding webpack externals example (#5)
* Adding webpack externals example * Self review * Updating directory structure and example * Moving to loading-dependencies folder
1 parent 966cb33 commit 149ae7f

File tree

6 files changed

+210
-0
lines changed

6 files changed

+210
-0
lines changed

loading-dependencies/webpack-externals/dist/bundle.js

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loading-dependencies/webpack-externals/dist/bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en-US">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>Webpack Externals - SystemJS Example</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<base href="/loading-dependencies/webpack-externals/">
9+
<script type="systemjs-importmap">
10+
{
11+
"imports": {
12+
"vue": "https://cdn.jsdelivr.net/npm/vue",
13+
"jupiter": "./dist/bundle.js"
14+
}
15+
}
16+
</script>
17+
<script src="https://cdn.jsdelivr.net/npm/systemjs/dist/system.js"></script>
18+
<script src="https://cdn.jsdelivr.net/npm/systemjs/dist/extras/amd.js"></script>
19+
<script src="https://cdn.jsdelivr.net/npm/systemjs/dist/extras/use-default.js"></script>
20+
</head>
21+
<body>
22+
<div id="vue-container"></div>
23+
<script>
24+
System.import('jupiter')
25+
</script>
26+
</body>
27+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "webpack-externals",
3+
"scripts": {
4+
"build": "webpack"
5+
},
6+
"license": "MIT",
7+
"devDependencies": {
8+
"clean-webpack-plugin": "^3.0.0",
9+
"webpack": "^4.41.2",
10+
"webpack-cli": "^3.3.10"
11+
},
12+
"dependencies": {}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Vue from 'vue';
2+
3+
console.log('Vue', Vue);
4+
5+
const App = Vue.default.extend({
6+
template: '<p>Jupiter has {{numMoons}} moons',
7+
data: () => ({
8+
numMoons: 79,
9+
})
10+
});
11+
12+
new App().$mount('#vue-container');
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require('path');
2+
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
3+
4+
module.exports = {
5+
entry: path.resolve(__dirname, 'src/entry.js'),
6+
mode: 'development',
7+
output: {
8+
filename: 'bundle.js',
9+
path: path.resolve(__dirname, 'dist'),
10+
libraryTarget: 'system',
11+
},
12+
devtool: 'sourcemap',
13+
plugins: [new CleanWebpackPlugin()],
14+
// Webpack externals will be shared across bundles and come from the import map and systemjs
15+
externals: ['vue', 'vue-router'],
16+
};

0 commit comments

Comments
 (0)