File tree Expand file tree Collapse file tree 5 files changed +121
-104
lines changed Expand file tree Collapse file tree 5 files changed +121
-104
lines changed Original file line number Diff line number Diff line change 11const path = require ( 'path' )
2+ const isGlobal = require ( 'installed-by-yarn-globally' )
23
3- module . exports = {
4- entry : path . resolve ( './src/index' ) ,
5- dist : path . resolve ( './dist' ) ,
4+ const appRoot = process . cwd ( )
5+
6+ const paths = {
7+ appRoot,
8+ entry : path . resolve ( './src/index.js' ) ,
9+ dist : path . resolve ( './build' ) ,
610 template : path . resolve ( './src/index.html' ) ,
711 favicon : path . resolve ( './src/favicon.ico' ) ,
12+ elmPkg : path . resolve ( 'elm-package.json' ) ,
813 ownModules : path . resolve ( __dirname , '../node_modules' ) ,
914 scripts : path . resolve ( __dirname , '../scripts' ) ,
10- elmMake : path . resolve ( __dirname , '../node_modules/.bin/elm-make' )
15+ elmMake : path . resolve ( __dirname , '../node_modules/.bin/elm-make' ) ,
16+ resolveLoaderModules : [ 'node_modules' ]
17+ }
18+
19+ // If installed globally by yarn, attemt to resolve loaders from the directory above.
20+ if ( isGlobal ) {
21+ paths . resolveLoaderModules . push ( path . resolve ( __dirname , '../../' ) )
1122}
23+
24+ module . exports = paths
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ module.exports = {
2020
2121 paths . entry
2222 ] ,
23+
2324 output : {
2425
2526 pathinfo : true ,
@@ -36,7 +37,7 @@ module.exports = {
3637 resolveLoader : {
3738
3839 // Look for loaders in own node_modules
39- modules : [ paths . ownModules ] ,
40+ modules : paths . resolveLoaderModules ,
4041 moduleExtensions : [ '-loader' ]
4142 } ,
4243
Original file line number Diff line number Diff line change @@ -8,8 +8,6 @@ const AssetsPlugin = require('assets-webpack-plugin')
88const getClientEnvironment = require ( './env' )
99const paths = require ( '../config/paths' )
1010
11- const root = process . cwd ( )
12-
1311module . exports = {
1412
1513 bail : true ,
@@ -24,7 +22,7 @@ module.exports = {
2422 path : paths . dist ,
2523
2624 // Append leading slash when production assets are referenced in the html.
27- publicPath : process . env . SERVED_PATH || '/' ,
25+ publicPath : './' || process . env . SERVED_PATH ,
2826
2927 // Generated JS files.
3028 filename : 'js/[name].[chunkhash:8].js'
@@ -38,7 +36,7 @@ module.exports = {
3836 } ,
3937
4038 resolve : {
41- modules : [ 'node_modules' ] ,
39+ modules : paths . resolveLoaderModules ,
4240 extensions : [ '.js' , '.elm' ]
4341 } ,
4442
@@ -123,7 +121,7 @@ module.exports = {
123121
124122 // Remove the content of the ./dist/ folder.
125123 new CleanWebpackPlugin ( [ 'dist' ] , {
126- root : root ,
124+ root : paths . appRoot ,
127125 verbose : false ,
128126 dry : false
129127 } ) ,
Original file line number Diff line number Diff line change 5959 "fs-extra" : " ^2.1.2" ,
6060 "html-webpack-plugin" : " 2.28.0" ,
6161 "http-proxy-middleware" : " ^0.17.3" ,
62+ "installed-by-yarn-globally" : " ^0.1.2" ,
6263 "minimist" : " 1.2.0" ,
6364 "postcss-loader" : " 1.3.3" ,
6465 "prompt" : " 1.0.0" ,
You can’t perform that action at this time.
0 commit comments