Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from gothinkster/esm
Browse files Browse the repository at this point in the history
Update webpack and other dependencies
  • Loading branch information
microbouji authored May 13, 2020
2 parents 46458b7 + 522fe6f commit 721bd67
Show file tree
Hide file tree
Showing 7 changed files with 3,936 additions and 1,973 deletions.
5 changes: 0 additions & 5 deletions app/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {CRegisterComponent} from "../pages/register.comp";
import {RouterOutlet} from "../router/router-outlet";
import {ComponentRegistry} from "./component-registry";
import {ProfileComponent} from "../pages/profile.comp";
import {ArticlePreviewComponent} from "../pages/article-preview.comp";
import {CommentPreviewComponent} from "../components/comment-preview.comp";
import {EditorComponent} from "../pages/editor.comp";
import {SettingsComponent} from "../pages/settings.comp";
Expand Down Expand Up @@ -61,10 +60,6 @@ const components = [
tagName: 'c-profile',
component: ProfileComponent
},
{
tagName: 'article-preview',
component: ArticlePreviewComponent
},
{
tagName: 'comment-preview',
component: CommentPreviewComponent
Expand Down
7 changes: 4 additions & 3 deletions app/pages/article-preview.comp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {Http} from "../http/http";
"use strict";
var markdown = require("markdown").markdown;


export class ArticlePreviewComponent extends HTMLElement {
class ArticlePreviewComponent extends HTMLElement {
constructor(params) {
super();
this.slug = params.slug;
Expand Down Expand Up @@ -105,3 +103,6 @@ export class ArticlePreviewComponent extends HTMLElement {


}

window.customElements.define('article-preview', ArticlePreviewComponent);
export default ArticlePreviewComponent;
10 changes: 8 additions & 2 deletions app/router/router-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {CLoginComponent} from "../pages/login.comp";
import {AuthDefender} from "../auth/auth-defender";
import {SettingsComponent} from "../pages/settings.comp";
import {EditorComponent} from "../pages/editor.comp";
import {ArticlePreviewComponent} from "../pages/article-preview.comp";
import {ProfileComponent} from "../pages/profile.comp";
import {CRegisterComponent} from "../pages/register.comp";
import {HomeComponent} from "../pages/home.comp";
Expand Down Expand Up @@ -42,7 +41,6 @@ export class RouterHandler {
{path: '/login', resolve: CLoginComponent},
{path: '/register', resolve: CRegisterComponent},
{path: '/profile/:username', resolve: ProfileComponent},
{path: '/article/:slug', resolve: ArticlePreviewComponent},
{path: '/editor/:slug', resolve: EditorComponent, canActivate: AuthDefender.canActivate},
{path: '/editor', resolve: EditorComponent, canActivate: AuthDefender.canActivate}
];
Expand All @@ -51,6 +49,14 @@ export class RouterHandler {
RouterHandler.inject(new HomeComponent())
}).resolve();

this.router.on(
'/article/:slug',
(params) => {
import('../pages/article-preview.comp.js').then((Component) =>
RouterHandler.inject(new Component.default(params))
);
}).resolve();

routes.forEach(route => {
this.router.on(
route.path,
Expand Down
22 changes: 9 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@
"dependencies": {
"@webcomponents/webcomponentsjs": "git://github.com/webcomponents/webcomponentsjs.git#v1.0.0",
"markdown": "^0.5.0",
"navigo": "^4.7.1",
"whatwg-fetch": "^2.0.3"
"navigo": "^7.1.2",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.24.1",
"copy-webpack-plugin": "^4.0.1",
"html-webpack-plugin": "^2.28.0",
"path": "^0.12.7",
"uglify-es": "git://github.com/mishoo/UglifyJS2#harmony",
"uglifyjs-webpack-plugin": "^0.4.3",
"webpack": "^2.5.1",
"webpack-dev-server": "^2.4.5"
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"babel-loader": "^8.1.0",
"html-webpack-plugin": "^4.2.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}
}
48 changes: 15 additions & 33 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
var webpack = require('webpack');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './app/index.html',
filename: 'index.html',
inject: 'body',
});
var CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
entry: ['whatwg-fetch', './app/index.js'],
output: {
path: path.resolve('dist'),
filename: 'index_bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {plugins: ['transform-decorators-legacy']}
},
{test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/}
]
},
plugins: [HtmlWebpackPluginConfig, new webpack.HotModuleReplacementPlugin(), new CopyWebpackPlugin([{
context: './app',
from: '**/*.html',
}]), new webpack.IgnorePlugin(/vertx/)],
devServer: {
hot: true,
contentBase: './',
historyApiFallback: true
}
mode: 'development',
entry: './app/index.js',
plugins: [
new HtmlWebpackPlugin({
template: './app/index.html'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.IgnorePlugin(/vertx/)
],
devServer: {
hot: true,
contentBase: './',
historyApiFallback: true
}
};
64 changes: 31 additions & 33 deletions webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
devtool: 'source-map',
entry: ['whatwg-fetch', './app/index.js'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new HtmlWebpackPlugin({
template: './app/index.html'
}),

new CopyWebpackPlugin([{
context: './app',
from: '**/*.html',
}]),
new webpack.IgnorePlugin(/vertx/)
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {plugins: ['transform-decorators-legacy']}
}
]
}
}
mode: 'production',
devtool: 'source-map',
entry: ['whatwg-fetch', './app/index.js'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './app/index.html'
}),
new webpack.IgnorePlugin(/vertx/)
]
};
Loading

0 comments on commit 721bd67

Please sign in to comment.