How webpack ignores import statements

in my main.js import router from". / router"

now I want to implement the webpack configuration
1. The command line npm run dev does not quote router , which means not writing this line of code
2. Quote router

when you use npm run build on the command line.

and how to ignore the content between certain characters, such as

/****/
import router from "./router"
/****/

the following is my project structure, solve!


import is static and cannot be loaded. It can be replaced with require to determine the environment variables.


answer on the same floor. In addition, import is syntactic sugar and is executed at compile time. The execution process is converted to require. So syntactically, it is not allowed to write import imports (non-import () outside the top part.
require is executed at run time, so it can be written in conditional judgment.

attached:

import router from './router'

 
const options = { }
if(process.env.NODE_ENV === 'router'){
   options.router = require('./router')
}

const vm = new Vue(options)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3324a-2be55.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3324a-2be55.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?