Created
March 28, 2020 15:56
-
-
Save oharsta/caf924efc828cd4896b95db33faa2466 to your computer and use it in GitHub Desktop.
IE11 Svelte Webpack configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
presets: [ | |
[ | |
'@babel/preset-env', | |
{ | |
debug: true, | |
"corejs": 3, | |
"useBuiltIns": "entry", | |
targets: ['last 2 versions', 'ie >= 11'] | |
}], | |
] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "core-js/stable"; | |
import "regenerator-runtime/runtime"; | |
import "isomorphic-fetch"; | |
import App from "./App.svelte"; | |
const app = new App({target: document.body}); | |
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"private": true, | |
"name": "svelte-gui", | |
"version": "0.0.1", | |
"license": "MIT", | |
"devDependencies": { | |
"@babel/core": "^7.7.2", | |
"@babel/preset-env": "^7.7.1", | |
"babel-jest": "^24.9.0", | |
"babel-loader": "^8.1.0", | |
"core-js": "^3.6.4", | |
"cross-env": "^6.0.3", | |
"css-loader": "^3.2.0", | |
"html-webpack-plugin": "^3.2.0", | |
"jest": "^24.9.0", | |
"mini-css-extract-plugin": "^0.8.0", | |
"regenerator-runtime": "^0.13.5", | |
"serialize-javascript": "^2.1.2", | |
"serve": "^11.2.0", | |
"style-loader": "^1.0.0", | |
"svelte": "^3.12.1", | |
"svelte-loader": "2.13.6", | |
"svelte-preprocess": "^3.6.0", | |
"svg-inline-loader": "^0.8.0", | |
"webpack": "^4.41.2", | |
"webpack-cli": "^3.3.9", | |
"webpack-dev-server": "^3.9.0" | |
}, | |
"scripts": { | |
"build": "cross-env NODE_ENV=production webpack", | |
"dev": "webpack-dev-server --open --content-base public", | |
"test": "jest src", | |
"test:watch": "npm run test -- --watch" | |
}, | |
"dependencies": { | |
"isomorphic-fetch": "^2.2.1", | |
"svelte-routing": "^1.4.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const path = require('path'); | |
const mode = process.env.NODE_ENV || 'development'; | |
const prod = mode === 'production'; | |
module.exports = { | |
entry: { | |
bundle: ['./src/main.js'] | |
}, | |
resolve: { | |
alias: { | |
svelte: path.resolve('node_modules', 'svelte') | |
}, | |
extensions: ['.mjs', '.js', '.svelte'], | |
mainFields: ['svelte', 'browser', 'module', 'main'] | |
}, | |
output: { | |
path: __dirname + '/public', | |
filename: '[name].[hash].js', | |
chunkFilename: '[name].[hash].js', | |
publicPath: '/', | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.m?js$/, | |
use: { | |
loader: 'babel-loader' | |
}, | |
exclude: /\bcore-js\b/, | |
}, | |
{ | |
test: /\.svelte$/, | |
use: [ | |
{ | |
loader: 'babel-loader', | |
}, | |
{ | |
loader: 'svelte-loader', | |
options: { | |
preprocess: require('svelte-preprocess')({ | |
postcss: true | |
}), | |
emitCss: true, | |
accessors: true, | |
dev: true | |
}, | |
} | |
], | |
}, | |
{ | |
test: /\.css$/, | |
use: [ | |
/** | |
* MiniCssExtractPlugin doesn't support HMR. | |
* For developing, use 'style-loader' instead. | |
* */ | |
prod ? MiniCssExtractPlugin.loader : 'style-loader', | |
'css-loader' | |
] | |
}, | |
{ | |
test: /\.svg$/, | |
loader: 'svg-inline-loader', | |
options: { | |
removeSVGTagAttrs: false | |
} | |
} | |
] | |
}, | |
mode, | |
plugins: [ | |
new MiniCssExtractPlugin({ | |
filename: '[name].[hash].css' | |
}), | |
new HtmlWebpackPlugin({ | |
template: "src/index.html.ejs", | |
favicon: "src/favicon.ico", | |
hash: true | |
}), | |
], | |
devtool: prod ? false : 'source-map', | |
devServer: { | |
port: 3000, | |
proxy: { | |
'/myconext/api': 'http://localhost:8081', | |
'/config': 'http://localhost:8081', | |
'/register': 'http://localhost:8081' | |
}, | |
historyApiFallback: true | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment