The only way I have successfully had webpack generate a non JavaScript file is to include an entry
for the primary asset. The problem is, webpack is generating a .js
file based on this asset as well, which is unnecessary. Is this the correct way of working with non JavaScript assets in a webpack config?
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const outputDir = 'build';
const extractStylus = new ExtractTextPlugin('../css/screen.css');
module.exports = {
entry: {
app: './src/js/index.js',
print: './src/js/print.js',
stylus: './src/stylus/screen.styl'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.styl$/,
use: extractStylus.extract({
fallback: 'style-loader',
use: ['css-loader', 'stylus-loader']
})
}
]
},
plugins: [extractStylus],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, `${outputDir}/js`)
}
};
The specific line in question is part of the entry
object:
stylus: './src/stylus/screen.styl'
Without that line, nothing is generated, but with that line, the expected .css
as well as a stylus.bundle.js
file are generated.