| 1 | package Mojo::Alien::webpack; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use File::chdir; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Mojo::Alien::npm; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Mojo::File qw(path tempfile); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Mojo::Loader; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use POSIX ':sys_wait_h'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Time::HiRes qw(sleep); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use constant DEBUG => ($ENV{MOJO_ROLLUP_DEBUG} || $ENV{MOJO_WEBPACK_DEBUG}) && 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=12.5
Condition40%2/5
($ENV{'MOJO_ROLLUP_DEBUG'} || $ENV{'MOJO_WEBPACK_DEBUG'}) && 1
$ENV{"MOJO_ROLLUP_DEBUG"} or $ENV{"MOJO_WEBPACK_DEBUG"}
MC/DC0%0/2
($ENV{'MOJO_ROLLUP_DEBUG'} || $ENV{'MOJO_WEBPACK_DEBUG'}) && 1
$ENV{"MOJO_ROLLUP_DEBUG"}
$ENV{"MOJO_WEBPACK_DEBUG"}
Truth table33%1/3
A or B
A= $ENV{"MOJO_ROLLUP_DEBUG"}B= $ENV{"MOJO_WEBPACK_DEBUG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # TODO | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | our $VERSION = $Mojolicious::Plugin::Webpack::VERSION || '0.01'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$Mojolicious::Plugin::Webpack::VERSION || '0.01'
MC/DC100%1/1
$Mojolicious::Plugin::Webpack::VERSION || '0.01'
$Mojolicious::Plugin::Webpack::VERSION
Truth table100%2/2
A
A= $Mojolicious::Plugin::Webpack::VERSION
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | has assets_dir => sub { shift->config->dirname->child('assets') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | has binary => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return $ENV{MOJO_WEBPACK_BINARY} if $ENV{MOJO_WEBPACK_BINARY}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $bin = $self->config->to_abs->dirname->child(qw(node_modules .bin webpack)); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $self->_d('%s %s', -e $bin ? 'Found' : 'Not installed', $bin) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return -e $bin ? $bin->to_string : 'webpack'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | has config => sub { path->to_abs->child('webpack.config.js') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | has dependencies => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | core => [qw(webpack webpack-cli)], | |||||||||||||||||||||||||||||||||||||||||
| 32 | css => [qw(css-loader mini-css-extract-plugin css-minimizer-webpack-plugin)], | ||||||||||||||||||||||||||||||||||||||||||
| 33 | eslint => [qw(eslint eslint-webpack-plugin)], | ||||||||||||||||||||||||||||||||||||||||||
| 34 | js => [qw(@babel/core @babel/preset-env @babel/plugin-transform-runtime babel-loader terser-webpack-plugin)], | ||||||||||||||||||||||||||||||||||||||||||
| 35 | sass => [qw(css-loader mini-css-extract-plugin css-minimizer-webpack-plugin sass sass-loader)], | ||||||||||||||||||||||||||||||||||||||||||
| 36 | vue => [qw(vue vue-loader vue-template-compiler)], | ||||||||||||||||||||||||||||||||||||||||||
| 37 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | has include => sub { +[] }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | has mode => sub { $ENV{NODE_ENV} || 'development' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | has npm => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | Mojo::Alien::npm->new(config => $self->config->dirname->child('package.json'), mode => $self->mode); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | has out_dir => sub { shift->config->dirname->child('dist') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | sub asset_map { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asset_map: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my %assets; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | for my $path ($self->out_dir->list_tree->each) { | |||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $rel_path = File::Spec->abs2rel($path, $self->out_dir); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | my $name = $rel_path; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | $name =~ s!(.*)\W(\w+)\.(\w+)$!$1.$3!; # (prefix, checksum, ext) | |||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $mode = ($2 // '') eq 'development' ? 'development' : 'production'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table50%1/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | $assets{$rel_path} = {ext => lc $3, name => $name, mode => $mode, mtime => $path->stat->mtime, path => $path}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | return \%assets; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub build { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | croak "Can't call build() after watch()" if $self->pid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ($!, $?) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->_run($self->_cmd_build); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | croak "$self->{basename} $! (exit=$?)" if $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | croak "$self->{basename} failed exit=$?" if !$! and $?; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $! and $?
MC/DC0%0/2
not $! and $?
not $!
$?
Truth table0%0/3
not(A) and B
A= not $!B= $?
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub exec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exec: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my @cmd = ($self->_cmd_build, '--watch'); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $home = $self->config->dirname->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | chdir $home or die "Can't chdir to $home: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $ENV{NODE_ENV} = $self->mode; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $ENV{WEBPACK_ASSETS_DIR} = $self->assets_dir->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $ENV{WEBPACK_OUT_DIR} = $self->out_dir->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->_d('(%s) cd %s && %s', $$, $home, join ' ', @_) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | { CORE::exec(@cmd) } | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | die "Can't exec @cmd: $!"; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $self->npm->init; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $self->_render_file($self->_config_template_name, $self->config); | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $dependencies = $self->npm->dependencies; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my @includes = @{$self->include}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | unshift @includes, 'core' unless grep { $_ eq 'core' } @includes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($conf_d, @includes_names, %seen) = ($self->_config_include_dir); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | for my $include (@includes) { | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | for my $package (@{$self->dependencies->{$include} || []}) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->dependencies->{$include} || []
MC/DC0%0/1
$self->dependencies->{$include} || []
$self->dependencies->{$include}
Truth table0%0/2
A
A= $self->dependencies->{$include}
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | next if $seen{$package}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $self->npm->install($package) unless $dependencies->{$package}{version}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $exists = $self->_resources->{"include/$include.js"} ? 'exists' : 'does not exist'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $file = $conf_d->child("$include.js"); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->_d('Template %s.js %s', $include, $exists) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $self->_render_file("include/$include.js", $file) if $exists eq 'exists'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | push @includes_names, $include if -e $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $include_src = ("module.exports = function(config, opts) {\n"); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $include_src .= " require('./$_')(config, opts);\n" for @includes_names; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $include_src .= "};\n"; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->_render_file('include.js', $self->_config_include_dir->child('include.js'), $include_src); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub pid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pid: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | return 0 unless $self->{pid}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $r = waitpid $self->{pid}, WNOHANG; # -1 == no such process, >0 if terminated | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return $r == -1 && delete $self->{pid} ? 0 : $r ? 0 : $self->{pid}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$r == -1 and delete $self->{"pid"}
MC/DC0%0/2
$r == -1 and delete $self->{"pid"}
$r == -1
delete $self->{"pid"}
Truth table0%0/3
A and B
A= $r == -1B= delete $self->{"pid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub stop { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my ($self, $tries) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | $tries ||= 100; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tries ||= 100
MC/DC0%0/1
$tries ||= 100
$tries
Truth table0%0/2
A
A= $tries
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | while (--$tries) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | return $self unless my $pid = $self->pid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | local $!; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | kill 15, $pid; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | waitpid $pid, 0; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sleep $ENV{MOJO_WEBPACK_STOP_INTERVAL} || 0.1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $self->{basename} ||= path($self->binary)->basename; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"basename"} ||= path($self->binary)->basename
MC/DC0%0/2
$self->{"basename"} ||= path($self->binary)->basename
$self->{"basename"}
path($self->binary)->basename
Truth table0%0/3
A ||= B
A= $self->{"basename"}B= path($self->binary)->basename
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | croak "Couldn't stop $self->{basename} with pid @{[$self->pid]}"; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub watch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
watch: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return $self if $self->pid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $home = $self->config->dirname->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | croak "Can't chdir $home: No such file or directory" unless -d $home; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my @cmd = ($self->_cmd_build, '--watch'); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | croak "Can't fork: $!" unless defined(my $pid = fork); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | return $self if $self->{pid} = $pid; # Parent | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return $self->exec; # Child | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub _cmd_build { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmd_build: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->init; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my @cmd = ($self->binary); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | croak "Can't run $cmd[0]" unless -x $cmd[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | $self->{basename} ||= path($cmd[0])->basename; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"basename"} ||= path($cmd[0])->basename
MC/DC0%0/2
$self->{"basename"} ||= path($cmd[0])->basename
$self->{"basename"}
path($cmd[0])->basename
Truth table0%0/3
A ||= B
A= $self->{"basename"}B= path($cmd[0])->basename
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | push @cmd, '--config' => $self->config->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | push @cmd, qw(--progress --profile --verbose) if $ENV{MOJO_WEBPACK_VERBOSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return @cmd; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub _config_include_dir { shift->assets_dir->child('webpack.config.d') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config_include_dir: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub _config_template_name {'webpack.config.js'} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config_template_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub _d { my ($class, $format) = (shift, shift); warn sprintf "[Webpack] $format\n", @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_d: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub _render_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_file: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my ($self, $name, $file, $content) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if (-e $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $version = $file->slurp =~ m!// Autogenerated.*(\d+\.\d+)! ? $1 : -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->_d('File %s has version %s', $file, $version) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return $self if $version == -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return $self if $version == $VERSION and !$content and !$ENV{MOJO_WEBPACK_REGENERATE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$version == $Mojo::Alien::webpack::VERSION and not $content and not $ENV{"MOJO_WEBPACK_REGENERATE"}
$version == $Mojo::Alien::webpack::VERSION and not $content
MC/DC0%0/3
$version == $Mojo::Alien::webpack::VERSION and not $content and not $ENV{"MOJO_WEBPACK_REGENERATE"}
$version == $Mojo::Alien::webpack::VERSION
not $content
not $ENV{"MOJO_WEBPACK_REGENERATE"}
Truth table0%0/4
A and not(B) and not(C)
A= $version == $Mojo::Alien::webpack::VERSIONB= not $contentC= not $ENV{"MOJO_WEBPACK_REGENERATE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $self->_d('Render %s to %s', $name, $file) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $file->dirname->make_path unless -d $file->dirname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $content //= $self->_resources->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$content //= $self->_resources->{$name}
MC/DC0%0/2
$content //= $self->_resources->{$name}
$content
$self->_resources->{$name}
Truth table0%0/3
A //= B
A= $contentB= $self->_resources->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $file->spurt(sprintf "// Autogenerated by %s %s\n%s", ref($self), $VERSION, $content); | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub _resources { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resources: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | state $resources = Mojo::Loader::data_section(ref($_[0]) || $_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub _run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | local $CWD = $self->config->dirname->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | local $ENV{NODE_ENV} = $self->mode; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | local $ENV{WEBPACK_ASSETS_DIR} = $self->assets_dir->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | local $ENV{WEBPACK_OUT_DIR} = $self->out_dir->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->_d('cd %s && %s', $CWD, join ' ', @cmd) if DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | open my $WEBPACK, '-|', @cmd or die "Can't run @cmd: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | return $WEBPACK if defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | DEBUG && print while <$WEBPACK>; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub DESTROY { shift->stop } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | Mojo::Alien::webpack - Runs the external nodejs program webpack | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | use Mojo::Alien::webpack; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | my $webpack = Mojo::Alien::webpack->new; | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | # Run once | ||||||||||||||||||||||||||||||||||||||||||
| 223 | $webpack->build; | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | # Build when webpack see files change | ||||||||||||||||||||||||||||||||||||||||||
| 226 | $webpack->watch; | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | L<Mojo::Alien::webpack> is a class for runnig the external nodejs program | ||||||||||||||||||||||||||||||||||||||||||
| 231 | L<webpack|https://webpack.js.org/>. | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | =head2 assets_dir | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | $path = $webpack->assets_dir; | ||||||||||||||||||||||||||||||||||||||||||
| 238 | $webpack = $webpack->assets_dir($webpack->config->dirname->child('assets')) | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | Location to source assetsa and partial webpack.config.js files. | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | =head2 binary | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | $array_ref = $webpack->binary; | ||||||||||||||||||||||||||||||||||||||||||
| 245 | $webpack = $webpack->binary('webpack'); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | The path to the webpack executable. Defaults to C<MOJO_WEBPACK_BINARY> | ||||||||||||||||||||||||||||||||||||||||||
| 248 | environment variable, or "webpack" inside "./node_modules". Fallback to just | ||||||||||||||||||||||||||||||||||||||||||
| 249 | "webpack". | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | =head2 config | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | $path = $webpack->config; | ||||||||||||||||||||||||||||||||||||||||||
| 254 | $webpack = $webpack->config(path->to_abs->child('webpack.config.js')); | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | Holds an I</absolute> path to | ||||||||||||||||||||||||||||||||||||||||||
| 257 | L<webpack.config.js|https://webpack.js.org/concepts/configuration/>. | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | =head2 dependencies | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | $hash_ref = $webpack->dependencies; | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | A hash where the keys can match the items in L</include> and the values are | ||||||||||||||||||||||||||||||||||||||||||
| 264 | lists of packages to install. Keys that does I</not> match items in L</include> | ||||||||||||||||||||||||||||||||||||||||||
| 265 | will be ignored. This attribute will be used by L</init>. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | These dependencies are predefined: | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | core | webpack webpack-cli | ||||||||||||||||||||||||||||||||||||||||||
| 270 | css | css-loader mini-css-extract-plugin css-minimizer-webpack-plugin | ||||||||||||||||||||||||||||||||||||||||||
| 271 | eslint | eslint-webpack-plugin | ||||||||||||||||||||||||||||||||||||||||||
| 272 | js | @babel/core @babel/preset-env @babel/plugin-transform-runtime babel-loader terser-webpack-plugin | ||||||||||||||||||||||||||||||||||||||||||
| 273 | sass | css-loader mini-css-extract-plugin css-minimizer-webpack-plugin sass sass-loader | ||||||||||||||||||||||||||||||||||||||||||
| 274 | vue | vue vue-loader vue-template-compiler | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =head2 include | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | $array_ref = $webpack->include; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | $webpack = $webpack->include([qw(js css)]); | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | L</include> can be used to install dependencies and load other webpack config | ||||||||||||||||||||||||||||||||||||||||||
| 282 | files. The config files included must exist in the "webpack.config.d" sub | ||||||||||||||||||||||||||||||||||||||||||
| 283 | directory inside L</assets_dir>. Here is an example of which files that will be | ||||||||||||||||||||||||||||||||||||||||||
| 284 | included if they exists: | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | # Including "js" and "css" will look for the files below | ||||||||||||||||||||||||||||||||||||||||||
| 287 | $webpack->include[qw(js css)]); | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # - assets/webpack.config.d/package-babel-loader.js | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # - assets/webpack.config.d/package-terser-webpack-plugin.js | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # - assets/webpack.config.d/package-css-loader.js | ||||||||||||||||||||||||||||||||||||||||||
| 292 | # - assets/webpack.config.d/package-css-minimizer-webpack-plugin.js | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # - assets/webpack.config.d/js.js | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # - assets/webpack.config.d/css.js | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | The L</include> feature is currently EXPERIMENTAL. | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | =head2 mode | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | $str = $webpack->mode; | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $webpack = $webpack->mode('development'); | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | Should be either "development" or "production". Will be used as "NODE_ENV" | ||||||||||||||||||||||||||||||||||||||||||
| 304 | environment variable when calling L</build> or L</watch>. | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | =head2 npm | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | $npm = $webpack->npm; | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | A L<Mojo::Alien::npm> object used by L</init>. | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | =head2 out_dir | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | $path = $webpack->out_dir; | ||||||||||||||||||||||||||||||||||||||||||
| 315 | $webpack = $webpack->out_dir(path('dist')->to_abs); | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | Location to write output assets to. | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | =head2 asset_map | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | $hash_ref = $webpack->asset_map; | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | Parses the filenames in L</out_dir> and returns a hash ref with information | ||||||||||||||||||||||||||||||||||||||||||
| 326 | about the generated assets. Example return value: | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 'relative/output.development.js' => { # Key is relative path to out_dir() | ||||||||||||||||||||||||||||||||||||||||||
| 330 | ext => 'css', # File extension | ||||||||||||||||||||||||||||||||||||||||||
| 331 | mode => 'development', # or "production" | ||||||||||||||||||||||||||||||||||||||||||
| 332 | mtime => 1616976114, # File modification epoch timestamp | ||||||||||||||||||||||||||||||||||||||||||
| 333 | name => 'relative/output.js', # Name of asset, without checksum or mode | ||||||||||||||||||||||||||||||||||||||||||
| 334 | path => '/path/to/entry-name.development.js', # Absolute path to asset | ||||||||||||||||||||||||||||||||||||||||||
| 335 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | Note that this method is currently EXPERIMENTAL. | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | =head2 build | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | $webpack->build; | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | Will build the assets or croaks on errors. Automatically calls L</init>. | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | =head2 exec | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | $webpack->exec; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | This method will replace the current process, instead of starting webpack | ||||||||||||||||||||||||||||||||||||||||||
| 351 | inside a fork. This method is called by L</watch> inside a fork. | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | =head2 init | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | $webpack = $webpack->init; | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | Will install "webpack" and "webpack-cli" and create a default L</config>. Does | ||||||||||||||||||||||||||||||||||||||||||
| 358 | nothing if this is already done. | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | This method is automatically called by L</build> and L</watch>. | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | =head2 pid | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | $int = $webpack->pid; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | Returns the PID of the webpack process started by L</start>. | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | =head2 stop | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | $webpack->stop; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | Will stop the process started by L</watch>. Does nothing if L</watch> has not | ||||||||||||||||||||||||||||||||||||||||||
| 373 | been called. | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | =head2 watch | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | $webpack->watch; | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | Forks a new process that runs "webpack watch". This means that any changes will | ||||||||||||||||||||||||||||||||||||||||||
| 380 | generate new assets. This is much more efficient than calling L</build> over | ||||||||||||||||||||||||||||||||||||||||||
| 381 | and over again. Automatically calls L</init>. | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | L<Mojolicious::Plugin::Webpack> and L<Mojo::Alien::rollup>. | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||