Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.
Draft
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: 4 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require "hanami_webpack/cli"

HanamiWebpack::CLI.start
1 change: 1 addition & 0 deletions hanami-webpack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Gem::Specification.new do |s|
s.license = 'MIT'

s.add_dependency 'hanami'
s.add_dependency "thor"
end
1 change: 1 addition & 0 deletions lib/hanami-webpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'hanami/utils/blank'
require 'hanami/config/security'
require_relative 'hanami_webpack/view_helper'
require_relative 'hanami_webpack/cli'
require_relative 'hanami_webpack/dev_server'
require_relative 'hanami_webpack/security_headers_hijack'

Expand Down
15 changes: 15 additions & 0 deletions lib/hanami_webpack/cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "thor"

module HanamiWebpack
class CLI < Thor
include Thor::Actions

source_root File.expand_path("../templates", File.dirname(__FILE__))

desc "setup", "Setup webpack and package.json"
def webpack
copy_file 'webpack.config.sample.js', './webpack.config.js'
copy_file 'package.sample.json', './package.json'
end
end
end
File renamed without changes.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "myApp",
"version": "0.0.1",
"devDependencies": {
"stats-webpack-plugin": "*",
"webpack": "*",
"webpack-dev-server": "*"
}
}
33 changes: 33 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var path = require("path"),
StatsPlugin = require("stats-webpack-plugin");

var devServerPort = process.env.WEBPACK_DEV_SERVER_PORT,
devServerHost = process.env.WEBPACK_DEV_SERVER_HOST,
publicPath = process.env.WEBPACK_PUBLIC_PATH;

var config = {
entry: {},

output: {
path: path.join(__dirname, "public"),
filename: "[name]-[chunkhash].js"
},

resolve: {
root: path.join(__dirname, "apps")
},

plugins: [
new StatsPlugin("webpack_manifest.json")
]
};

if (process.env.INBUILT_WEBPACK_DEV_SERVER) {
config.devServer = {
port: devServerPort,
headers: { "Access-Control-Allow-Origin": "*" }
};
config.output.publicPath = "//" + devServerHost + ":" + devServerPort + "/";
}

module.exports = config;