Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins and loaders #7

Open
wants to merge 1 commit into
base: PluginsLoaders
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Message from './model/message.model';
import template from './messages.html';

console.log('Index started');
console.dir(new Message());

/* eslint no-undef: 0 */
document.getElementById('send').onclick = () => {
const m = new Message(document.getElementById('message').value);
document.getElementById('messages').innerHTML +=
`<li>${m.text} ${m.created}</li>`;
document.getElementById('messages').innerHTML += template(m);
};

if (module && module.hot) {
Expand Down
1 change: 1 addition & 0 deletions app/messages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<li>${this.text} - ${this.created}</li>
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
},
"homepage": "https://github.com/Especializa/es6#readme",
"devDependencies": {
"eslint": "^3.14.0",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-import": "^2.2.0",
"express": "^4.14.1",
"html-es6-template-loader": "^1.0.1",
"html-webpack-plugin": "^2.28.0",
"http-server": "^0.9.0",
"nodemon": "^1.11.0",
"webpack": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.3.0"
"eslint": "^4.16.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"express": "^4.16.2",
"html-es6-template-loader": "^1.0.5",
"html-webpack-plugin": "^2.30.1",
"http-server": "^0.11.1",
"nodemon": "^1.14.11",
"webpack": "^3.10.0",
"webpack-dev-middleware": "^2.0.4",
"webpack-dev-server": "^2.11.1"
}
}
21 changes: 18 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
entry: './app/index.js',
Expand All @@ -8,6 +9,22 @@ const config = {
filename: 'bundle.js',
publicPath: '/',
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'app', 'index.html'),
}),
],
module: {
loaders: [
{
loader: 'html-es6-template-loader',
test: /\.html$/,
query: {
transpile: true,
},
},
],
},
};

if (process.env.NODE_ENV === 'development') {
Expand All @@ -18,9 +35,7 @@ if (process.env.NODE_ENV === 'development') {
config.devServer = {
hot: true,
};
config.plugins = [
new webpack.HotModuleReplacementPlugin(),
];
config.plugins.push(new webpack.HotModuleReplacementPlugin());
}

module.exports = config;