|
| 1 | +const path = require('path'); |
| 2 | + |
| 3 | +const BrowserSyncPlugin = require('browser-sync-webpack-plugin') |
| 4 | + |
| 5 | + |
| 6 | +module.exports = { |
| 7 | + entry: './src/index.tsx', |
| 8 | + output: { |
| 9 | + filename: 'bundle.js', |
| 10 | + path: path.resolve(__dirname, 'dist') |
| 11 | + }, |
| 12 | + // Enable sourcemaps for debugging webpack's output. |
| 13 | + devtool: "source-map", |
| 14 | + |
| 15 | + resolve: { |
| 16 | + // Add '.ts' and '.tsx' as resolvable extensions. |
| 17 | + extensions: [".ts", ".tsx", ".js", ".json"] |
| 18 | + }, |
| 19 | + |
| 20 | + |
| 21 | + module: { |
| 22 | + rules: [ |
| 23 | + // All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'. |
| 24 | + { test: /\.tsx?$/, loader: "awesome-typescript-loader" }, |
| 25 | + |
| 26 | + // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'. |
| 27 | + { enforce: "pre", test: /\.js$/, loader: "source-map-loader" } |
| 28 | + ] |
| 29 | + }, |
| 30 | + |
| 31 | + devServer: { |
| 32 | + contentBase: path.join(__dirname, 'dist'), |
| 33 | + }, |
| 34 | + // When importing a module whose path matches one of the following, just |
| 35 | + // assume a corresponding global variable exists and use that instead. |
| 36 | + // This is important because it allows us to avoid bundling all of our |
| 37 | + // dependencies, which allows browsers to cache those libraries between builds. |
| 38 | + externals: { |
| 39 | + // "react": "React", |
| 40 | + // "react-dom": "ReactDOM" |
| 41 | + }, |
| 42 | + |
| 43 | + plugins: [ |
| 44 | + new BrowserSyncPlugin({ |
| 45 | + host: 'localhost', |
| 46 | + port: 3000, |
| 47 | + proxy: 'http://localhost:8080/', |
| 48 | + files: ['./dist/**/*'], |
| 49 | + browser: 'google chrome' |
| 50 | + }) |
| 51 | + ] |
| 52 | +}; |
0 commit comments