Skip to content

Instantly share code, notes, and snippets.

@dimitrilahaye
Last active June 5, 2018 07:55
Show Gist options
  • Save dimitrilahaye/45aa99a3ec7f9fcea9528531f9c93d86 to your computer and use it in GitHub Desktop.
Save dimitrilahaye/45aa99a3ec7f9fcea9528531f9c93d86 to your computer and use it in GitHub Desktop.
Simple webpack configuration for export / import

Launch commands :

npm install
npm run webpack
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>My app !</title>
</head>
<body>
<script src="dist/bundle.js"></script>
</body>
</html>
{
"name": "modules",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "npm run webpack",
"webpack": "webpack -d --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.0.0-beta.49",
"@babel/preset-env": "^7.0.0-beta.49",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.0-beta.3",
"babel-preset-env": "^1.7.0",
"node-libs-browser": "^2.1.0",
"webpack": "^4.10.2",
"webpack-cli": "^3.0.2"
}
}
let path = require('path');
module.exports = {
entry: ['./src/app.js'], // entry point of the application
output: {
filename: './bundle.js' // will build the app into ./dist/bundle.js
},
module: {
rules: [
{
loader: 'babel-loader',
test: path.join(__dirname, 'app'),
query: {
presets: 'env'
}
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment