Skip to content

Instantly share code, notes, and snippets.

npm install --save-dev style-loader css-loader
ERROR in ./style.css
Module parse failed: /path-to-project/style.css Line 1: Unexpected token {
You may need an appropriate loader to handle this file type.
require('./style.css');
var print = require('./print.js');
document.write(print);
body {
background: #0f0;
}
module.exports = {
entry: ['./src/index.js'],
output: {
filename: './dist/bundle.js'
}
}
dist/
src/
index.js
print.js
style.css
index.html
package.json
webpack.config.js
module.exports = {
entry: ['./index.js'],
output: {
filename: './bundle.js'
}
};
<!DOCTYPE html>
<html>
<head>
<title>Webpack test</title>
<script type="text/javascript" src="./bundle.js"></script>
</head>
<body>
</body>
</html>
webpack index.js bundle.js
var print = require('./print.js');
document.write(print);