Tweak webpack config

This commit is contained in:
Pig Fang 2019-11-26 13:01:15 +08:00
parent a724543dac
commit 0fbf16acad
9 changed files with 26 additions and 63 deletions

View File

@ -57,7 +57,7 @@ class FootComposer
if (Str::startsWith(config('app.asset.env'), 'dev')) {
$scripts[] = $this->webpack->url('style.js');
}
$scripts[] = $this->webpack->url('index.js');
$scripts[] = $this->webpack->url('app.js');
$view->with([
'scripts' => $scripts,

View File

@ -46,7 +46,6 @@
"@typescript-eslint/parser": "^2.8.0",
"@vue/test-utils": "^1.0.0-beta.29",
"autoprefixer": "^9.7.2",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-dynamic-import-node": "^2.3.0",
@ -58,7 +57,6 @@
"eslint-config-gplane": "^6.2.1",
"eslint-formatter-beauty": "^3.0.0",
"eslint-plugin-vue": "^6.0.1",
"expose-loader": "^0.7.5",
"file-loader": "^3.0.1",
"jest": "^24.9.0",
"jest-extended": "^0.11.2",
@ -156,12 +154,18 @@
}
},
{
"files": ["resources/assets/tests/**/*.ts", "*.d.ts"],
"files": [
"resources/assets/tests/**/*.ts",
"*.d.ts"
],
"rules": {
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/unbound-method": 0,
"@typescript-eslint/no-extra-parens": 0,
"max-len": [2, 120]
"max-len": [
2,
120
]
}
},
{

View File

@ -1,6 +1,6 @@
import Vue from 'vue'
import loadI18n from './scripts/i18n-text'
import './scripts'
import './scripts/app'
import routes from './scripts/route'
Vue.config.productionTip = false

View File

@ -1,5 +1,4 @@
import './public-path' // Must be first
import $ from 'jquery'
import './init' // Must be first
import 'bootstrap'
import 'admin-lte'
import './i18n'

View File

@ -1,5 +1,9 @@
/* eslint-disable prefer-const */
/* eslint-disable @typescript-eslint/camelcase */
import $ from 'jquery'
// @ts-ignore
declare let __webpack_public_path__: string
const url = new URL(blessing.base_url)
@ -8,3 +12,6 @@ url.port = '8080'
__webpack_public_path__ = process.env.NODE_ENV === 'development'
? url.toString()
: `${blessing.base_url}/app/`
// @ts-ignore
window.$ = window.jQuery = $ // eslint-disable-line

View File

@ -189,7 +189,7 @@ class AdminFormsTest extends BrowserKitTestCase
$this->visit('/admin/resource')
->type('', 'cdn_address')
->press('submit_resources');
$this->visit('/')->dontSee('url/app/index.js');
$this->visit('/')->dontSee('url/app/app.js');
$this->visit('/admin/resource')
->check('enable_redis')

View File

@ -48,15 +48,15 @@ class FootComposerTest extends TestCase
->atLeast(1)
->andReturn('style.js');
$mock->shouldReceive('url')
->with('index.js')
->with('app.js')
->twice()
->andReturn('index.js');
->andReturn('app.js');
});
$this->get('/user')
->assertSee('en.js')
->assertSee('en_plugin.js')
->assertSee('index.js')
->assertSee('app.js')
->assertDontSee('check-updates.js');
$superAdmin = factory(User::class, 'superAdmin')->make();

View File

@ -1,4 +1,3 @@
const fs = require('fs')
const sass = require('sass')
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
@ -14,7 +13,7 @@ const devMode = !process.argv.includes('-p')
const config = {
mode: devMode ? 'development' : 'production',
entry: {
index: './resources/assets/src/index.ts',
app: './resources/assets/src/index.ts',
'check-updates': './resources/assets/src/scripts/check-updates.ts',
'language-chooser': './resources/assets/src/scripts/language-chooser.ts',
style: [
@ -112,19 +111,6 @@ const config = {
test: /\.(svg|woff2?|eot|ttf)$/,
loader: devMode ? 'url-loader' : 'file-loader',
},
{
test: require.resolve('jquery'),
use: [
{
loader: 'expose-loader',
options: 'jQuery',
},
{
loader: 'expose-loader',
options: '$',
},
],
},
],
noParse: /^(vue|jquery)$/,
},
@ -149,7 +135,6 @@ const config = {
host: '0.0.0.0',
hot: true,
hotOnly: true,
public: getDevServerUrl(),
stats: 'errors-only',
},
stats: 'errors-only',
@ -164,13 +149,3 @@ if (devMode) {
}
module.exports = config
function getDevServerUrl() {
const matches = /ASSET_URL=(.*)/.exec(fs.readFileSync('.env', 'utf8'))
if (!matches) {
return
}
const url = new URL(matches[1])
return `${url.host}:8080`
}

View File

@ -378,7 +378,7 @@
esutils "^2.0.2"
js-tokens "^4.0.0"
"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.4.3", "@babel/parser@^7.4.4", "@babel/parser@^7.4.5":
"@babel/parser@^7.1.0", "@babel/parser@^7.4.3", "@babel/parser@^7.4.4", "@babel/parser@^7.4.5":
version "7.4.5"
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.4.5.tgz#04af8d5d5a2b044a2a1bffacc1e5e6673544e872"
integrity sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==
@ -858,7 +858,7 @@
"@babel/parser" "^7.7.0"
"@babel/types" "^7.7.0"
"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.4.3", "@babel/traverse@^7.4.4", "@babel/traverse@^7.4.5":
"@babel/traverse@^7.1.0", "@babel/traverse@^7.4.3", "@babel/traverse@^7.4.4", "@babel/traverse@^7.4.5":
version "7.4.5"
resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.5.tgz#4e92d1728fd2f1897dafdd321efbff92156c3216"
integrity sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==
@ -2024,18 +2024,6 @@ aws4@^1.8.0:
resolved "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
babel-eslint@^10.0.3:
version "10.0.3"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.3.tgz#81a2c669be0f205e19462fed2482d33e4687a88a"
integrity sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/parser" "^7.0.0"
"@babel/traverse" "^7.0.0"
"@babel/types" "^7.0.0"
eslint-visitor-keys "^1.0.0"
resolve "^1.12.0"
babel-helper-vue-jsx-merge-props@^2.0.0:
version "2.0.3"
resolved "https://registry.npmjs.org/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz#22aebd3b33902328e513293a8e4992b384f9f1b6"
@ -4153,11 +4141,6 @@ eslint-utils@^1.4.3:
dependencies:
eslint-visitor-keys "^1.1.0"
eslint-visitor-keys@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==
eslint-visitor-keys@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
@ -4375,11 +4358,6 @@ expect@^24.1.0, expect@^24.9.0:
jest-message-util "^24.9.0"
jest-regex-util "^24.9.0"
expose-loader@^0.7.5:
version "0.7.5"
resolved "https://registry.npmjs.org/expose-loader/-/expose-loader-0.7.5.tgz#e29ea2d9aeeed3254a3faa1b35f502db9f9c3f6f"
integrity sha512-iPowgKUZkTPX5PznYsmifVj9Bob0w2wTHVkt/eYNPSzyebkUgIedmskf/kcfEIWpiWjg3JRjnW+a17XypySMuw==
express@^4.17.1:
version "4.17.1"
resolved "https://registry.npmjs.org/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
@ -8612,7 +8590,7 @@ resolve@1.x, resolve@^1.10.0:
dependencies:
path-parse "^1.0.6"
resolve@^1.1.5, resolve@^1.12.0:
resolve@^1.1.5:
version "1.12.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.0.tgz#3fc644a35c84a48554609ff26ec52b66fa577df6"
integrity sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==