update webpack & dependencies

This commit is contained in:
amphineko 2019-12-07 03:59:14 +08:00
parent b0ec112b0c
commit d7d2d4eb6d
No known key found for this signature in database
GPG Key ID: 4582E6587852EF42
3 changed files with 2693 additions and 2236 deletions

7534
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,23 +13,26 @@
}, },
"homepage": "https://futa.moe/amphineko/", "homepage": "https://futa.moe/amphineko/",
"scripts": { "scripts": {
"build": "node_modules/.bin/webpack -p" "build": "webpack -p",
"start": "webpack-dev-server"
}, },
"devDependencies": { "devDependencies": {
"@fortawesome/fontawesome-free": "^5.8.1", "@fortawesome/fontawesome-free": "^5.11.2",
"browser-sync": "^2.26.3", "browser-sync": "^2.26.7",
"browser-sync-webpack-plugin": "^2.2.2", "browser-sync-webpack-plugin": "^2.2.2",
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^2.1.1", "css-loader": "^2.1.1",
"extract-loader": "^3.1.0", "extract-loader": "^3.1.0",
"file-loader": "^3.0.1", "file-loader": "^3.0.1",
"html-loader": "^0.5.5", "html-loader": "^0.5.5",
"mini-css-extract-plugin": "^0.5.0", "mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.11.0", "node-sass": "^4.13.0",
"resolve-url-loader": "^3.1.0", "resolve-url-loader": "^3.1.1",
"sass-loader": "^7.1.0", "sass-loader": "^7.3.1",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"unsemantic": "^1.2.3", "unsemantic": "^1.2.3",
"webpack": "^4.29.6", "webpack": "^4.41.2",
"webpack-cli": "^3.3.0" "webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
} }
} }

View File

@ -1,14 +1,23 @@
const path = require('path') const path = require('path')
const BrowserSyncPlugin = require('browser-sync-webpack-plugin') const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin') const { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = (env, argv) => { module.exports = (env, argv) => {
const isProduction = argv.mode === 'production' const isProduction = argv.mode === 'production'
console.log(`Using mode ${isProduction ? 'PRODUCTION' : 'DEVELOPMENT'}`)
return { return {
context: path.resolve(__dirname, 'src'), context: path.resolve(__dirname, 'src'),
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
port: 3100,
},
devtool: 'inline-source-map',
mode: isProduction ? 'production' : 'development', mode: isProduction ? 'production' : 'development',
entry: { entry: {
@ -71,11 +80,16 @@ module.exports = (env, argv) => {
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
}, },
plugins: [ plugins: Array.prototype.concat([
new CleanWebpackPlugin(),
], isProduction
? []
: [
new BrowserSyncPlugin({ new BrowserSyncPlugin({
host: 'localhost', host: 'localhost',
server: { baseDir: ['dist'] }, open: false,
}) proxy: 'http://localhost:3100/',
], }),
])
} }
} }