1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- const path = require('path')
- const CopyWebpackPlugin = require('copy-webpack-plugin')
- function resolve(dir) {
- return path.join(__dirname, dir)
- }
- const projectName = process.env.PROJECT
- const port = process.env.port || process.env.npm_config_port || 9527
- const publicDir = 'src/projects/' + projectName + '/public/'
- const settings = require('./src/projects/' + projectName + '/settings.js')
- module.exports = {
- outputDir: '../../public/' + projectName,
- publicPath: '/' + projectName + '/',
- assetsDir: 'static',
- lintOnSave: process.env.NODE_ENV === 'development',
- productionSourceMap: false,
- devServer: {
- port: port,
- // open: true,
- overlay: {
- warnings: false,
- errors: true
- }
- },
- css: {
- loaderOptions: {
- postcss: {
- plugins: [require('tailwindcss'), require('autoprefixer')]
- }
- }
- },
- configureWebpack: {
- name: settings.title,
- externals: {
- jquery: "jQuery",
- },
- resolve: {
- alias: {
- '@@': resolve('src'),
- '@': resolve('src/projects/' + projectName)
- }
- },
- // configure public as a static assets folder
- plugins: [
- new CopyWebpackPlugin([{ from: publicDir, to: '', toType: 'dir' }])
- ],
- performance: {
- hints: 'warning',
- maxEntrypointSize: 50000000,
- maxAssetSize: 30000000,
- assetFilter: function(assetFilename) {
- return assetFilename.endsWith('.js')
- }
- }
- },
- chainWebpack(config) {
- config.plugin('preload').tap(() => [
- {
- rel: 'preload',
- // to ignore runtime.js
- fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
- include: 'initial'
- }
- ])
- // when there are many pages, it will cause too many meaningless requests
- config.plugins.delete('prefetch')
- // to configure public as the location of the template
- config.plugin('html').tap(args => {
- args[0].template = path.resolve(publicDir + '/index.html')
- return args
- })
- }
- }
|