Skip to content

Commit 2fb9b7d

Browse files
Pauansendilkumarn
authored andcommitted
Changing to use copy-webpack-plugin
1 parent 02acd4f commit 2fb9b7d

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

template/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# You must adjust these to your own details.
22
[package]
3-
name = "template"
3+
name = "rust-webpack-template"
44
description = "My super awesome Rust, WebAssembly, and Webpack project!"
55
version = "0.1.0"
66
authors = ["You <[email protected]>"]

template/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ npm test -- --chrome
3030
# Runs tests in Safari
3131
npm test -- --safari
3232
```
33+
34+
# What does each file do?
35+
36+
* `Cargo.toml` contains the standard Rust metadata. You put your Rust dependencies in here. You should adjust this file with your details (name, author, etc.)
37+
38+
* `package.json` contains the standard npm metadata. You put your JavaScript dependencies in here. You should adjust this file with your details (name, author, etc.)
39+
40+
* `webpack.config.js` contains the Webpack configuration. You shouldn't need to change this, unless you have very special needs.
41+
42+
* The `js` folder contains your JavaScript code (`index.js` is used to hook everything into Webpack, you don't need to change it).
43+
44+
* The `src` folder contains your Rust code.
45+
46+
* The `static` folder contains any files that you want copied as-is into the final build. It contains an `index.html` file which loads the `index.js` file.
47+
48+
* The `tests` folder contains your Rust unit tests.

template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"devDependencies": {
1111
"@wasm-tool/wasm-pack-plugin": "^0.4.2",
12-
"html-webpack-plugin": "^3.2.0",
12+
"copy-webpack-plugin": "^5.0.3",
1313
"webpack": "^4.33.0",
1414
"webpack-cli": "^3.3.3",
1515
"webpack-dev-server": "^3.7.1",

template/index.html renamed to template/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<title>My Rust + Webpack project!</title>
66
</head>
77
<body>
8-
8+
<script src="index.js"></script>
99
</body>
1010
</html>

template/webpack.config.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
const path = require("path");
2-
const HtmlWebpackPlugin = require("html-webpack-plugin");
2+
const CopyPlugin = require("copy-webpack-plugin");
33
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
44

55
const dist = path.resolve(__dirname, "dist");
66

77
module.exports = {
88
mode: "production",
9-
entry: "./js/index.js",
9+
entry: {
10+
index: "./js/index.js"
11+
},
1012
output: {
1113
path: dist,
1214
filename: "[name].js"
@@ -15,9 +17,9 @@ module.exports = {
1517
contentBase: dist,
1618
},
1719
plugins: [
18-
new HtmlWebpackPlugin({
19-
template: "index.html"
20-
}),
20+
new CopyPlugin([
21+
path.resolve(__dirname, "static")
22+
]),
2123

2224
new WasmPackPlugin({
2325
crateDirectory: __dirname,

0 commit comments

Comments
 (0)