Giter Club home page Giter Club logo

laravel-mix's Introduction

Laravel Mix

Node NPM NPM NPM

Introduction

Laravel Mix thumbnail

Laravel Mix provides a clean, fluent API for defining basic webpack build steps for your applications. Mix supports several common CSS and JavaScript pre-processors.

If you've ever been confused about how to get started with module bundling and asset compilation, you will love Laravel Mix!

Documentation

You may review the initial documentation here.

License

Laravel Mix is open-sourced software licensed under the MIT license.

laravel-mix's People

Contributors

ankurk91 avatar apasov avatar bvangraafeiland avatar claytonrcarter avatar darkaonline avatar deframe avatar dependabot[bot] avatar dotnetcarpenter avatar eblin avatar epreston avatar forehalo avatar jeffreyway avatar jthomaschewski avatar knowler avatar kristofmorva avatar lkmadushan avatar michaeldeboey avatar noeldemartin avatar ruchernchong avatar sebastiandedeyne avatar sebastians90 avatar soilspoon avatar stevieyu avatar thecrypticace avatar tillkruss avatar tiran133 avatar tpraxl avatar vinceg avatar vinkla avatar yansern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-mix's Issues

Using SCSS in Vue components

I'm looking for a way to tell laravel-mix to use the sass-loader when it comes across the following in a Vue component.

<style lang="scss">
   // random scss
</style>

The issue at hand is that there isn't really an scss-loader. sass-loader is used for both scss and sass, however by default whenever vue-loader sees lang="scss" it tries to find scss-loader.

I could just use lang="sass", however this causes most text editors to highlight (would-be) sass errors.

When using laravel-elixir I'm able to get around this by adding the following snippet to my webpack.config.js file.

module.exports = {
  vue: {
    loaders: {
      js: 'buble-loader',
      scss: 'vue-style-loader!css-loader!sass-loader'
    }
  }
}

I'm currently using the mix.webpackConfig method to change other configuration, however I'm not sure what options I need to pass in to accomplish my goals.

NPM run dev using --watch-poll automatically ends the process after compiling

normal npm run dev without -poll does not read file changes. so I added the -poll flag
but the the problem is after I run the npm run dev after compiling it automatically ends the process making it the same as running npm run webpack

  • Windows 10
  • Latest Laravel Homestead
{
  "private": true,
  "scripts": {
    "webpack": "cross-env NODE_ENV=development webpack --progress --hide-modules",
    "dev": "cross-env NODE_ENV=development webpack --watch-poll --progress --hide-modules",
    "hmr": "cross-env NODE_ENV=development webpack-dev-server --inline --hot",
    "production": "cross-env NODE_ENV=production webpack --progress --hide-modules"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "gulp": "^3.9.1",
    "laravel-mix": "^0.2.10",
    "lodash": "^4.16.2",
    "vue": "^2.0.1"
  }
}

mix.combine: Cannot read property 'reduce' of undefined

Not sure if it is me who is doing something wrong, any suggestions?

node -v: 6.9.4
npm -v: 4.0.5

script:
mix.combine([ 'resources/assets/js/lib/MooTools-Core-1.6.0.js', 'resources/assets/js/lib/MooTools-More-1.6.0.js', 'resources/assets/js/classes/ui.class.js', 'resources/assets/js/classes/menu.class.js', 'resources/assets/js/classes/login.class.js', 'resources/assets/js/classes/article.class.js', 'resources/assets/js/classes/modal.class.js', 'resources/assets/js/classes/articles.class.js', 'resources/assets/js/classes/page.class.js', 'resources/assets/js/classes/forms.class.js', 'resources/assets/js/classes/read.class.js', 'resources/assets/js/classes/ui_elements.class.js' ], 'public/js/admin.js');

error:

/Users/jellebreuer/Code/valda/node_modules/laravel-mix/src/Mix.js:70
let entry = this.js.reduce((result, paths) => {
^

TypeError: Cannot read property 'reduce' of undefined
at Mix.entry (/Users/jellebreuer/Code/valda/node_modules/laravel-mix/src/Mix.js:70:28)
at Object. (/Users/jellebreuer/Code/valda/node_modules/laravel-mix/setup/webpack.config.js:46:28)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireConfig (/Users/jellebreuer/Code/valda/node_modules/webpack/bin/convert-argv.js:97:18)
at /Users/jellebreuer/Code/valda/node_modules/webpack/bin/convert-argv.js:110:17
at Array.forEach (native)
at module.exports (/Users/jellebreuer/Code/valda/node_modules/webpack/bin/convert-argv.js:108:15)
at Object. (/Users/jellebreuer/Code/valda/node_modules/webpack/bin/webpack.js:152:40)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)

How to build multiple css files?

This works:

mix
  .js('assets/js/admin.js', 'dist/js/')
  .js('assets/js/frontend.js', 'dist/js/')
;

However, this doesn't:

mix
  .sass('assets/sass/admin.scss', 'dist/css/')
  .sass('assets/sass/frontend.scss', 'dist/css/')
;

It results in the following error:

Error: Laravel Mix: Limit your "mix.sass()" calls to one.

Is this a bug or an intended limitation?

Issue on NPM Install

I had the following errors while installing laravel-mix on a fresh Laravel 5.3 installation.
UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of webpack@^2.1.0-beta.19 but none was installed.
npm WARN [email protected] requires a peer of webpack@^2.1.0-beta.26 but none was installed.

node version: 6.9.2
npm version: 3.10.8

I have not been able to go further than this.

{{ mix }} function should take devServer.host into account when running HMR

My current setup is a Homestead VM running the Laravel Mix Example on my Mac.

When i npm run hmr the node.js server is started on localhost, which i cannot access outside the VM.

Adding host: "laravel-mix.app" within webpack.config.js i get the following output:

Project is running at http://laravel-mix.app:8080/
webpack output is served from http://localhost:8080/
404s will fallback to /index.html

I've added port 8080 to my Homestead ports, and can now access the node server from my local machine.

When using the mix() function in a blade template, the localhost:8080 is hardcoded into the asset path, and not pulled from the webpack config file, thus making the loading of assets fail when accessing the site in my local browser.

I think the fix might be a bit more complex than just editing the path, as i tried hardcoding the url to laravel-mix.app instead, but still no dice.

Cannot GET /

On 'npm run hmr' I get the error 'Cannot GET /' when visiting localhost:8080 . It also can't find <script src="http://localhost:8080/js/app.js"></script> in Laravel 5.3. I also get this error when working with other webpack builds in both Wamp & Homestead Laravel environments.

Output path issue with mix.sass()

Hi,

I started using this a few days ago on a Node project, works perfectly fine with Vue!

But today I wanted to work a bit on styling and I do encounter an issue with the .sass() method.

Here's my config used in webpack.mix.js:

mix.js('resources/js/app.js', 'public/app.js')
    .sass('resources/sass/app.scss', 'public/app.css')

And here's the output of the terminal when running npm run dev or npm run webpack:

Chunk Names
  fonts/glyphicons-halflings-regular.eot?f4769f9bdb7466be65088239c12046d1  20.1 kB     [emitted]
  fonts/glyphicons-halflings-regular.svg?89889688147bd7575d6327160d64e760   109 kB     [emitted]
  fonts/glyphicons-halflings-regular.ttf?e18bbf611f2a2e43afc071aa2f4e1512  45.4 kB     [emitted]
 fonts/glyphicons-halflings-regular.woff?fa2772327f55d8198301fdb8bcfc8158  23.4 kB     [emitted]
fonts/glyphicons-halflings-regular.woff2?448c34a56d699c29117adc64c43affeb    18 kB     [emitted]
                                                            public/app.js   344 kB  0  [emitted]  app
                                                                 /app.css   688 kB  0  [emitted]  app

As you can see, the JS output is fine, it's where it should be, but the CSS file is put at the root folder of my project.

I'm using bootstrap-sass, so it looks that it is automatically moving the fonts, but again they should go into the public folder, but I don't really know how I can configure that.

My app.scss file is currently importing bootstrap-sass, and there's a single class in it:

@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

.top-spacing {
    margin-top: 10px;
}

It seems that the specified output path is truncated, because I gave it a try by using public/public/app.css, and it actually works!

Just in case, here's my directory structure:

- node_modules
- public
- resources
    - js
        app.js
    - sass
        app.scss
webpack.config.js
webpack.mix.js

Thanks in forward for your help, I'm also looking into the code to see what could be the issue, but no success so far!

dist/css/* → dicss/*

Kicking the tyres and noticed a strange thing happening. I am unsure whether it's something I've goofed or a side-effect of the folder structure I'm aiming for.

let mix = require("laravel-mix").mix

mix.js("src/js/app.js", "dist/js")
mix.sass("src/scss/app.scss", "dist/css")

./src/scss/app.scss is compiled to ./dicss/app.css.

let mix = require("laravel-mix").mix

mix.js("src/js/app.js", "build")
mix.sass("src/scss/app.scss", "build")

./src/scss/app.scss is compiled to ./buiapp.css.

Error ELIFECYCLE

When trying to run this on a mac, I get:

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.4.0/bin/node" "/usr/local/bin/npm" "run" "webpack"
npm ERR! node v7.4.0
npm ERR! npm  v4.1.1
npm ERR! code ELIFECYCLE
npm ERR! [email protected] webpack: `cross-env NODE_ENV=development webpack --progress --hide-modules`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the [email protected] webpack script 'cross-env NODE_ENV=development webpack --progress --hide-modules'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the 2017.sucks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack --progress --hide-modules
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 2017.sucks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 2017.sucks
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/alex/Development/2017.sucks/npm-debug.log

log file:


0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.4.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'webpack' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prewebpack', 'webpack', 'postwebpack' ]
5 info lifecycle [email protected]~prewebpack: [email protected]
6 silly lifecycle [email protected]~prewebpack: no script for prewebpack, continuing
7 info lifecycle [email protected]~webpack: [email protected]
8 verbose lifecycle [email protected]~webpack: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~webpack: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/alex/Development/2017.sucks/node_modules/.bin:/Users/alex/.cargo/bin:/Users/alex/Development/spark-installer:/Users/alex/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/alex/.yarn/bin
10 verbose lifecycle [email protected]~webpack: CWD: /Users/alex/Development/2017.sucks
11 silly lifecycle [email protected]~webpack: Args: [ '-c',
11 silly lifecycle   'cross-env NODE_ENV=development webpack --progress --hide-modules' ]
12 silly lifecycle [email protected]~webpack: Returned: code: 255  signal: null
13 info lifecycle [email protected]~webpack: Failed to exec webpack script
14 verbose stack Error: [email protected] webpack: `cross-env NODE_ENV=development webpack --progress --hide-modules`
14 verbose stack Exit status 255
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:885:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /Users/alex/Development/2017.sucks
17 error Darwin 16.3.0
18 error argv "/usr/local/Cellar/node/7.4.0/bin/node" "/usr/local/bin/npm" "run" "webpack"
19 error node v7.4.0
20 error npm  v4.1.1
21 error code ELIFECYCLE
22 error [email protected] webpack: `cross-env NODE_ENV=development webpack --progress --hide-modules`
22 error Exit status 255
23 error Failed at the [email protected] webpack script 'cross-env NODE_ENV=development webpack --progress --hide-modules'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the 2017.sucks package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     cross-env NODE_ENV=development webpack --progress --hide-modules
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs 2017.sucks
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls 2017.sucks
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

HMR not working

In my Homestead environment and hosts file I mapped the Laravel project to an 'projectname.app' url. When I run the 'npm run hmr' the localhost:8080 ain't working. Also curious how to integrate BrowserSync.

npm run dev SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

I followed the instruction and this is what I get using
os: ubuntu 16.04 desktop.

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle [email protected]~predev: [email protected]
6 silly lifecycle [email protected]~predev: no script for predev, continuing
7 info lifecycle [email protected]~dev: [email protected]
8 verbose lifecycle [email protected]~dev: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~dev: PATH: /usr/share/npm/bin/node-gyp-bin:/opt/lampp/htdocs/ecampus/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle [email protected]~dev: CWD: /opt/lampp/htdocs/ecampus
11 silly lifecycle [email protected]~dev: Args: [ '-c',
11 silly lifecycle   'cross-env NODE_ENV=development webpack --watch --progress --hide-modules' ]
12 silly lifecycle [email protected]~dev: Returned: code: 1  signal: null
13 info lifecycle [email protected]~dev: Failed to exec dev script
14 verbose stack Error: [email protected] dev: `cross-env NODE_ENV=development webpack --watch --progress --hide-modules`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at EventEmitter.emit (events.js:172:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at ChildProcess.emit (events.js:172:7)
14 verbose stack     at maybeClose (internal/child_process.js:821:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid [email protected]
16 verbose cwd /opt/lampp/htdocs/ecampus
17 error Linux 4.4.0-57-generic
18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
19 error node v4.2.6
20 error npm  v3.5.2
21 error code ELIFECYCLE
22 error [email protected] dev: `cross-env NODE_ENV=development webpack --watch --progress --hide-modules`
22 error Exit status 1
23 error Failed at the [email protected] dev script 'cross-env NODE_ENV=development webpack --watch --progress --hide-modules'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the ecampus package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     cross-env NODE_ENV=development webpack --watch --progress --hide-modules
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs ecampus
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls ecampus
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

.version() doesnt version combined files

.version() doesn't seem to version combined files, is there some way to force this?
Else this would make it not fully backwards compatible with elixir right?

Can we Have BrowserSync added?

Right Now , if we Run npm run hmr , and we change anything in our vue files its being hot reloaded....
But what if we change something in our blade files?

I hope we Can Use Again Browsersync like in laravel elixir,
lets say we will proxy it on localhost:3000
and still we have it also hot reloaded... at localhost:8080 via npm run hmr...
hope we can add some alias like npm run browsersync...
which behind the scene will check any changes in our blade template...

Sass array & appropriate loader

My code looks like this

mix.js([
        'resources/assets/js/frontend/app.js',
        'resources/assets/js/plugin/sweetalert/sweetalert.min.js',
        'resources/assets/js/plugins.js'
    ], 'public/js/frontend.js')
.sass([
        'frontend/app.scss',
        'plugin/sweetalert/sweetalert.scss',
    ], 'public/css/frontend.css')
 .version();

and what I get is

> @ dev c:\laragon\www\personal                                                                                                        
> cross-env NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js   
                                                                                                                                       
path.js:7                                                                                                                              
    throw new TypeError('Path must be a string. Received ' + inspect(path));                                                           
    ^                                                                                                                                  
                                                                                                                                       
TypeError: Path must be a string. Received [ 'frontend/app.scss', 'plugin/sweetalert/sweetalert.scss' ]                                
    at assertPath (path.js:7:11)    

edit

trying just the .js now.

ERROR in ./resources/assets/js/components/frontend/Calculator.vue                                                                         
Module parse failed: c:\laragon\www\personal\resources\assets\js\components\frontend\Calculator.vue Unexpected token (1:0)                
You may need an appropriate loader to handle this file type.                                                                              
| <template>                                                                                                                              
|     <div class="form-group">                                                                                                            
|         <div class="row">                                                                                                               
 @ ./resources/assets/js/frontend/app.js 16:28-76                                                                                         
 @ multi frontend  

node - v : v7.4.0
npm -v : 4.0.5
Windows + Laragon

Slow performance

This is good but it compiles slower than laravel elixir gulp. why?

mix.copy error

im receiving this error when i use mix.copy in my webpack.mix.js

npm run webpack

> @ webpack /mnt/c/Users/uriah/sites/royalflush
> cross-env NODE_ENV=development webpack --progress --hide-modules

/mnt/c/Users/uriah/sites/royalflush/node_modules/laravel-mix/src/index.js:128
        to: Mix.root(to)
                ^

TypeError: Mix.root is not a function
    at Object.module.exports.copy (/mnt/c/Users/uriah/sites/royalflush/node_modules/laravel-mix/src/index.js:128:17)
    at Object.<anonymous> (/mnt/c/Users/uriah/sites/royalflush/webpack.mix.js:15:5)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Mix.initialize (/mnt/c/Users/uriah/sites/royalflush/node_modules/laravel-mix/src/Mix.js:35:9)
    at Object.<anonymous> (/mnt/c/Users/uriah/sites/royalflush/webpack.config.js:18:5)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

npm ERR! Linux 4.4.0-43-Microsoft
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "webpack"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! @ webpack: `cross-env NODE_ENV=development webpack --progress --hide-modules`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ webpack script 'cross-env NODE_ENV=development webpack --progress --hide-modules'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack --progress --hide-modules
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/c/Users/uriah/sites/royalflush/npm-debug.log


Output path of mix.js()

First of all... Awesome work! Runs a lot faster then gulp.

But i have a problem, here is my mix file:

mix.js('./JS/default.js', '../Assets/js/default.js')
   .sass('./SASS/default.scss', '../Assets/css/default.css');

This is the result from the terminal:

.Assets/js/default.js 2.74 kB 0 [emitted] app
../Assets/css/default.css 461 bytes 0 [emitted] app

As you can see. The path for SASS works as expected but the JS path removes one dot and slash.

Order of vendor loading

I am using Bootstrap-sass (laravel). This requires jQuery. When I load the page, it keeps saying that bootstrap-sass needs jQuery, even though it has been loaded. However, jQuery comes after Bootstrap in vendor.js.

This is my mix:

mix.js('resources/assets/js/app.js', 'public/js')
   .extract(['jquery', 'vue', 'vue-cookie', 'vue-resource', 'axios', 'lodash', 'moment', 'autosize', 'bootstrap-sass'])
   .sass('resources/assets/sass/app.scss', 'public/css');

Is there a way to load jQuery first?

Also.. The Vue interceptor gives a Uncaught TypeError: Cannot read property 'interceptors' of undefined error:

Vue.http.interceptors.push((request, next) => { // Here
    request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);

    next();
});

Vue is being defined in the laravel bootstrap.js. Will this compile automaticly? I require it inside app.js.

wrong output path for mix.js

Hello,

Awwesome work!!! Finally I can use watch and hmr, it's magic!

But I have one problem with the output path for mix.js()

mix.js('resources/assets/js/pages/dashboard/index.js', './public/js/dashboard/')

results in an output of /js/index.js 3.01 kB 7 [emitted] index.

What am I doing wrong?

npm run webpack error

When this is defined:

mix.sass('resources/assets/sass/styles.scss', 'public/css');

But not this:

mix.js('resources/assets/js/app.js', 'public/js');

in webpack.mix.js the following error occurs.

npm run dev

> @ dev /foo/bar
> webpack --watch --progress --hide-modules

/foo/bar/node_modules/laravel-mix/src/Mix.js:45
            return [this.js.entry.path, this[this.cssPreprocessor].src.path];
                           ^

TypeError: Cannot read property 'entry' of undefined
    at Object.entry (/foo/bar/node_modules/laravel-mix/src/Mix.js:45:28)
    at Object.<anonymous> (/foo/bar/webpack.config.js:34:35)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at requireConfig (/foo/bar/node_modules/webpack/bin/convert-argv.js:98:18)
    at /foo/bar/node_modules/webpack/bin/convert-argv.js:111:17
    at Array.forEach (native)
    at module.exports (/foo/bar/node_modules/webpack/bin/convert-argv.js:109:15)
    at Object.<anonymous> (/foo/bar/node_modules/webpack/bin/webpack.js:141:40)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.3.0/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.3.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `webpack --watch --progress --hide-modules`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script 'webpack --watch --progress --hide-modules'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack --watch --progress --hide-modules
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /foo/bar/npm-debug.log

HMR not Working when using Copy Plugin

npm run hmr

mix.js('resources/assets/js/app.js', 'public/js')
mix.copy('node_modules/bootstrap/fonts', 'public/fonts')

This error preventing hot reload from working:

ERROR in [copy-webpack-plugin] Using older versions of webpack-dev-server, devServer.outputPath must be defined to write to absolute paths

npm run hmr

mix.js('resources/assets/js/app.js', 'public/js')
//mix.copy('node_modules/bootstrap/fonts', 'public/fonts')

Works.

I tried to use the output path as an absolute path but it can't find any js file.

Extract not work well with version

Version function creates new hash everytime when something change even for "vendor files (manifest, vendor). So everytime I need downloading all files again.

I have never use Webpack before, just research some articles about that. Maybe it is related to using [hash] instead of [chunkhash]. Article about this https://medium.com/@okonetchnikov/long-term-caching-of-static-assets-with-webpack-1ecb139adb95

Some interesting thoughts about hashing are there webpack/webpack-dev-server#377

Closing this, because you should not use [chunkhash] or [hash] for development. This will cause many other issues, like a memory leak, because the dev server does not know when to clean up the old files.

Double .sass

My code

let mix = require('laravel-mix').mix;

mix.js([
        'resources/assets/js/frontend/app.js',
        'resources/assets/js/plugin/sweetalert/sweetalert.min.js',
        'resources/assets/js/plugins.js'
    ], 'public/js/frontend-test.js')
    .js([
        'resources/assets/js/backend/app.js',
        'resources/assets/js/plugin/sweetalert/sweetalert.min.js',
        'resources/assets/js/plugin/toastr/toastr.min.js',
        'resources/assets/js/plugins.js',
        'resources/assets/js/backend/custom.js',
    ], 'public/js/backend-test.js')
    .copy(
        'node_modules/font-awesome/fonts',
         'resources/assets/sass/fonts/font-awesome')
    .copy(
        'node_modules/summernote/dist/font',
        'public/css/font'
    )
    .sass('resources/assets/sass/frontend/app.scss', 'public/css/frontend-test.css')
    .sass('resources/assets/sass/backend/app.scss', 'public/css/backend-test.css')
    .version();

Error: Laravel Mix: Limit your "mix.sass()" calls to one.

I looked through documentation but couldn't find anything.

sass inside import css run production terminal display error

app.scss

@import "~normalize.css/normalize.css";

run webpack or dev or hmr display normal
but run production, The following error is displayed

  warning  in ./~/css-loader!./~/postcss-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./resources/assets/sass/app.scss

  resolve-url-loader cannot operate: CSS error
  /Users/stevie/project/company/code/amii_web/laravel/resources/assets/sass/app.scss:2:474: missing '{'
  at error (/Users/stevie/project/company/code/amii_web/laravel/node_modules/css/lib/parse/index.js:62:15)

 @ ./resources/assets/sass/app.scss 4:14-236
 @ multi app

I can not find the reason

Can't use only SASS

For example, if I want to use only sass mix it will fail:

mix.sass('resources/assets/sass/app.scss', 'public/css/app.css')

Error:

./node_modules/laravel-mix/src/Mix.js:70
        let entry = this.js.reduce((result, paths) => {
                           ^

TypeError: Cannot read property 'reduce' of undefined

If js mix is included , when everything is OK:

mix.js('resources/assets/js/app.js', 'public/js/test.js')
    .sass('resources/assets/sass/app.scss', 'public/css/app.css')

It looks like you must always include js mix

UNMET PEER DEPENDENCY [email protected]

When I try to install laravel-mix via
npm install laravel-mix --save-dev
I always get the following error message:
UNMET PEER DEPENDENCY [email protected]
and at the bottom:
npm WARN [email protected] requires a peer of webpack@^2.1.0-beta.19 but none was installed. npm WARN [email protected] requires a peer of webpack@^2.1.0-beta.26 but none was installed.

I run this in a fresh installation of Homestead and got into the vm via vagrant ssh.

Mix versioning helper function will be made available for 5.1 LTS projects ?

I am already using webpack and gulp with the latest elixir on 5.1 LTS so moving to mix should be fairly easy to take advantage of hmr and library code splitting!

However I am versioning my js and css files which rely on the elixir global Function to grab the respective file.

As i understand the equivalent mix function will be available in laravel 5.4. Will this function be made available to install in 5.1 LTS so we can take advantage of mix in laravel projects prior to 5.4?

Fantastic Work Jeffrey!

Thanks Jeffrey for your fantastic work!
Already tested it a little bit, really amazing!
As I know you, I think you'll polish that even more and add some features.
I saw something that didn't work yet. But I'll wait until you say it's is "finished".
I don't want that you think I expect a finished product yet^^
Just wanted to say thank you 😊

Invalid configuration object

Using master, this:

mix.js('resources/assets/js/web.js', 'public/js')
   .js('resources/assets/js/app.js', 'public/js');

Results in:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry['app'] should be one of these:
   string | [string]
   The entry point for one output file.
 - configuration.entry should be one of these:
   object { <key>: string | [string] } | string | [string]
   The entry point(s) of the compilation.

Is there something I'm doing wrong? Totally new to Webpack.

Webpack-HMR - HTTPS

We can start webpack-dev-server in https mode by adding -https but the files loading in always come from http , is this because of webpack or something you've setup in mix?

Windows Symlinks

Just wanted to report an issue that I had with this on Windows and Homestead that others might come across. It may make sense to include this somewhere in the documentation (maybe even the Homestead documentation, as well).

For windows users using Homestead, npm cannot make symlinks unless the command prompt is run with administrator privileges. Typically, to get around this, you can run npm install --no-bin-links to force no symlinks. That works well, for most everything. However, because the Laravel Mix npm scripts require the node_modules/.bin directory to contain the symlinks, Windows users in non-elevated sessions will see a cross-env: command not found error.

In Summary: if you're a windows user with homestead, you'll have make sure to run vagrant up and npm install in a command prompt with admin privileges.

Error

Hi! When you run got the following error:

npm run webpack
> cross-env NODE_ENV=development webpack --progress --hide-modules

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn webpack ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/7.3.0/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "run" "webpack"
npm ERR! node v7.3.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! @ webpack: `cross-env NODE_ENV=development webpack --progress --hide-modules`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ webpack script 'cross-env NODE_ENV=development webpack --progress --hide-modules'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack --progress --hide-modules
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

Absolute path for fonts

Hi,

right now Webpack outputs fonts inside the css folder.

screen shot 2017-01-11 at 12 31 10 pm

updating webpack.conf.js from

{
            test: /\.(woff2?|ttf|eot|svg)$/,
            loader: 'file-loader',
            options: {
                name: '/fonts/[name].[ext]?[hash]'
            }
        }

to

name: '../fonts/[name].[ext]?[hash]'

fix the issue

Thanks

> cross-env NODE_ENV=development webpack --watch --progress --hide-modules sh: 1: cross-env: not found

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 silly lifecycle @~predev: no script for predev, continuing
7 info lifecycle @~dev: @
8 verbose lifecycle @~dev: unsafe-perm in lifecycle true
9 verbose lifecycle @~dev: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/opt/lampp/htdocs/amafv-ecampus/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle @~dev: CWD: /opt/lampp/htdocs/amafv-ecampus
11 silly lifecycle @~dev: Args: [ '-c',
11 silly lifecycle 'cross-env NODE_ENV=development webpack --watch --progress --hide-modules' ]
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: cross-env NODE_ENV=development webpack --watch --progress --hide-modules
13 verbose stack spawn ENOENT
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/lib/utils/spawn.js:33:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:877:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid @
15 verbose cwd /opt/lampp/htdocs/amafv-ecampus
16 error Linux 4.4.0-59-generic
17 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
18 error node v6.9.4
19 error npm v3.10.10
20 error file sh
21 error code ELIFECYCLE
22 error errno ENOENT
23 error syscall spawn
24 error @ dev: cross-env NODE_ENV=development webpack --watch --progress --hide-modules
24 error spawn ENOENT
25 error Failed at the @ dev script 'cross-env NODE_ENV=development webpack --watch --progress --hide-modules'.
25 error Make sure you have the latest version of node.js and npm installed.
25 error If you do, this is most likely a problem with the package,
25 error not with npm itself.
25 error Tell the author that this fails on your system:
25 error cross-env NODE_ENV=development webpack --watch --progress --hide-modules
25 error You can get information on how to open an issue for this project with:
25 error npm bugs
25 error Or if that isn't available, you can get their info via:
25 error npm owner ls
25 error There is likely additional logging output above.
26 verbose exit [ 1, true ]

mix() method not working in Blade templates

Hello, I am on Laravel Framework version 5.3.28 and have installed Laravel Mix via NPM. Using the version() API option results in the following error in my blade template: Call to undefined function mix() (View: /var/www/html/servicedesk/resources/views/welcome.blade.php)

I am implementing in the following way, per docs:

<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<script src="{{ mix('js/app.js') }}"></script>

How can I resolve this?

Windows Homestead Watchers

Just wanted to share an additional Windows/Homestead-related caveat/workaround that I encountered for anybody else who is having trouble with their configuration.

My Environment

  • Windows 10, Homestead , VirtualBox 5.1.12
  • Node 6.9.1
  • NPM 3.10.8
  • Laravel Mix 0.2.5

File Watchers

When running npm run dev the files would compile properly, but no changes were being watched from the Windows side. Editing a file in the Windows environment didn't trigger a recompile. If I edited the same file in VIM on the virtual machine, everything recompiles as expected. To get around the fact that Windows changes weren't being seen, I added the --watch-poll flag to the dev and hmr scripts in my package.json. Polling isn't as efficient, however, so I'm wondering if anyone has any better workarounds?

Cache folder is not automatically created

Not a huge deal, but public/output paths are automatically created. If the cache folder is missing but setCachePath is used, a built terminates in the following error: Error: ENOENT: no such file or directory, open 'cache/Mix.json'

"laravel-mix" is not in the npm registry.

When running npm install laravel-mix --save-dev the following error occurs:

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/laravel-mix
npm ERR! 404
npm ERR! 404  'laravel-mix' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

I'm not gonna steal the name 😉

Errors with JSX (React) and Sass

Environment: Windows10 -> Homestead -> Vagrant
NPM: 4.0.5
Node: 7.3.0
Laravel: 5.3

package.json:

{
  "private": true,
  "scripts": {
    "webpack": "cross-env NODE_ENV=development webpack --progress --hide-modules",
    "dev": "cross-env NODE_ENV=development webpack --watch --progress --hide-modules",
    "hmr": "cross-env NODE_ENV=development webpack-dev-server --inline --hot",
    "production": "cross-env NODE_ENV=production webpack --progress --hide-modules"
  },
  "devDependencies": {
    "laravel-mix": "^0.2.8"
  },
  "dependencies": {
    "detect-browser": "^1.5.0",
    "jquery": "^3.1.1",
    "lodash": "^4.17.3",
    "react": "^15.4.1",
    "react-dom": "^15.4.1"
  }
}

The errors (npm run dev):

ERROR in ./~/css-loader!./~/postcss-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./resources/assets/sass/app.scss
Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/LaravelProject/node_modules/node-sass/vendor'
    at Object.fs.readdirSync (fs.js:870:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/LaravelProject/node_modules/node-sass/lib/extensions.js:122:13)
    at foundBinariesList (/home/vagrant/Code/LaravelProject/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/LaravelProject/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/LaravelProject/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/LaravelProject/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/LaravelProject/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/LaravelProject/node_modules/sass-loader/index.js:4:12)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:164:2)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:160:10)
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:168:18
    at loadLoader (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:164:2)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:160:10)
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:168:18
 @ ./resources/assets/sass/app.scss 4:14-236
 @ multi app

ERROR in ./resources/assets/lib/HelloWorld.jsx
Module parse failed: /home/vagrant/Code/LaravelProject/resources/assets/lib/HelloWorld.jsx Unexpected token (14:12)
You may need an appropriate loader to handle this file type.
|     _render() {
|         ReactDom.render(
|             <h1>{this._text}</h1>,
|             this._container
|         )
 @ ./resources/assets/js/app.js 3:0-31
 @ multi app

ERROR in ./resources/assets/sass/app.scss
Module build failed: Error
    at /home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModule.js:143:35
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:359:11
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:165:18
    at loadLoader (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/loadLoader.js:27:11)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:164:2)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:160:10)
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:168:18
    at loadLoader (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:164:2)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:160:10)
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:168:18
    at loadLoader (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:164:2)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:160:10)
    at /home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:168:18
    at loadLoader (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:164:2)
    at runLoaders (/home/vagrant/Code/LaravelProject/node_modules/loader-runner/lib/LoaderRunner.js:357:2)
    at NormalModule.doBuild (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModule.js:131:2)
    at NormalModule.build (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModule.js:179:15)
    at Compilation.buildModule (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/Compilation.js:128:9)
    at Compilation.<anonymous> (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/Compilation.js:405:8)
    at /home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModuleFactory.js:74:13
    at /home/vagrant/Code/LaravelProject/node_modules/tapable/lib/Tapable.js:168:11
    at NormalModuleFactory.<anonymous> (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/CompatibilityPlugin.js:52:4)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/vagrant/Code/LaravelProject/node_modules/tapable/lib/Tapable.js:172:13)
    at onDoneResolving (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModuleFactory.js:49:11)
    at onDoneResolving (/home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModuleFactory.js:180:6)
    at /home/vagrant/Code/LaravelProject/node_modules/webpack/lib/NormalModuleFactory.js:176:6
    at /home/vagrant/Code/LaravelProject/node_modules/webpack/node_modules/async/dist/async.js:3694:9

ERROR in /home/vagrant/Code/LaravelProject/node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"remove":true}!/home/vagrant/Code/LaravelProject/node_modules/style-loader/index.js!/home/vagrant/Code/LaravelProject/node_modules/css-loader/index.js!/home/vagrant/Code/LaravelProject/node_modules/postcss-loader/index.js!/home/vagrant/Code/LaravelProject/node_modules/resolve-url-loader/index.js!/home/vagrant/Code/LaravelProject/node_modules/sass-loader/index.js?sourceMap!/home/vagrant/Code/LaravelProject/resources/assets/sass/app.scss doesn't export content

Use cross-env for NODE_ENV

Haven't looked through everything yet, but in your scripts your are using

"scripts": {
  "webpack": "webpack --progress --hide-modules",
  "dev": "webpack --watch --progress --hide-modules",
  "hmr": "webpack-dev-server --inline --hot",
  "production": "export NODE_ENV=production && webpack --progress --hide-modules"
}

Where export is not supported in non-UNIX platforms. I suggest pulling in cross-env as additional dev dependency.

This way, I am able to run yarn run production and npm run production on windows.

Mix.root not a function - error when using mix.copy

when using mix.copy() I get the following error:

TypeError: Mix.root is not a function at Object.module.exports.copy (/Users/me/project/node_modules/laravel-mix/src/index.js:128:17) at Object.<anonymous> (/Users/me/project/webpack.mix.js:18:7) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Mix.initialize (/Users/me/project/node_modules/laravel-mix/src/Mix.js:35:9) at Object.<anonymous> (/Users/me/project/node_modules/laravel-mix/setup/webpack.config.js:18:5) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)

npm ERR! Darwin 16.3.0 npm ERR! argv "/usr/local/Cellar/node@6/6.9.2/bin/node" "/usr/local/bin/npm" "run" "webpack" npm ERR! node v6.9.2 npm ERR! npm v3.10.8 npm ERR! code ELIFECYCLE npm ERR! @ webpack: cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js npm ERR! Exit status 1

Mix.json in production

Hi Jeffrey

I played a little bit with laravel-mix and I really love it so far.
But how would you use it in production?
I normally compiled everything locally, so I don't have to compile the scripts on deployment.
That worked really great with Laravel Elixir.
Now I need access to the Mix.json if I use .version()or .extract().
Sure I can move it to another folder with .setCachePath() and add it to git.
But the file is in my case over 6MB.

Therefore I tried to lower the file size. I saw that even the source code is in that file. Changing the the stats property in the webpack.config.js just changes the console output on compile, but not the Mix.json content.

What's your opinion?
Is it possible to optimize the Mix.json file?
Is the source code in that file necessary? If yes, also for production?

Just ask if I didn't provide enough information! 😊

Not envoyer linked folder compatible

Alright so for my website i used to run gulp production on envoyer just fine, with node_modules as a linked folder so npm install wouldn't take forever. Now when i try to run npm run production things go wrong because of this line in paths.js:

return path.resolve(__dirname, '../../../', append)

because its in a linked folder mix now thinks ./website is the root and not ./website/releases/number
when i nano into this file on the server and add the folder path to this line it works.

Can anyone think of a work around? for now i just removed the linked folder and wait a little longer for a deploy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.