Skip to content
Permalink
Browse files

feat(template-webpack): add file-loader/style-loader for handling the…

… static CSS file
  • Loading branch information
malept committed Jul 11, 2019
1 parent 7c963aa commit 054a458af14f0520e661d4f3b07850da4444541b
@@ -11,7 +11,9 @@ class WebpackTemplate implements ForgeTemplate {
`@electron-forge/plugin-webpack@${currentVersion}`,
// TODO: Use the @zeit publish once https://github.com/zeit/webpack-asset-relocator-loader/pull/41 has been merged
'@marshallofsound/webpack-asset-relocator-loader@^0.5.0',
'file-loader@^4.0.0',
'node-loader@^0.6.0',
'style-loader@^0.23.1',
];

public initializeTemplate = async (directory: string) => {
@@ -46,6 +48,7 @@ class WebpackTemplate implements ForgeTemplate {
let indexContents = await fs.readFile(path.resolve(directory, 'src', 'index.js'), 'utf8');
indexContents = indexContents.split('\n').map((line) => {
if (line.includes('mainWindow.loadURL')) return ' mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);';
if (line.includes('link rel="stylesheet"')) return '';
return line;
}).join('\n');
await fs.writeFile(path.resolve(directory, 'src', 'main.js'), indexContents);
@@ -26,4 +26,6 @@
* ```
*/

console.log(`👋 This message is being logged by "renderer.js", included via webpack`);
import url from './index.css';

console.log('👋 This message is being logged by "renderer.js", included via webpack');
@@ -1,6 +1,13 @@
const rules = require('./webpack.rules');

rules.push({
test: /\.css$/,
use: [{ loader: 'style-loader/url' }, { loader: 'file-loader' }],
});

module.exports = {
// Put your normal webpack config below here
module: {
rules: require('./webpack.rules'),
rules,
},
};

0 comments on commit 054a458

Please sign in to comment.
You can’t perform that action at this time.