ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
webpack.config.js ``` const { resolve } = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: './src/index.js', output: { filename: 'js/[name].js', path: resolve(__dirname, 'build') }, module: { rules: [ // loader的配置 { test: /\.css$/, // 多个loader用use use: ['style-loader', 'css-loader'] }, { test: /\.js$/, // 排除node_modules下的js文件 exclude: /node_modules/, // 只检查 src 下的js文件 include: resolve(__dirname, 'src'), // 优先执行 enforce: 'pre', // 延后执行 // enforce: 'post', // 单个loader用loader loader: 'eslint-loader', options: {} }, { // 以下配置只会生效一个 oneOf: [] } ] }, plugins: [new HtmlWebpackPlugin()], mode: 'development' }; ``` src/add.js ``` function add(x, y) { return x + y; } export default add; ``` src/count.js ``` function count(x, y) { return x - y; } export default count; ``` src/index.js ``` import count from './count'; console.log('index.js文件加载了~'); import('./add').then(({ default: add }) => { console.log(add(1, 2)); }); console.log(count(3, 2)); ```