Skip to content

Instantly share code, notes, and snippets.

@movii
Last active December 6, 2018 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save movii/34cd5f59a5bace0ecebe4e7e572d3100 to your computer and use it in GitHub Desktop.
Save movii/34cd5f59a5bace0ecebe4e7e572d3100 to your computer and use it in GitHub Desktop.
// 在 webpack.config.js 中通过 resolve.alias
// 预定义“目标文件夹”的 shortcut
module.exports = {
filename: 'bundle.js',
publicPath: 'http://localhost:1333/dist/'
},
+ resolve:{
+ alias: {
+ JS_ROOT: path.resolve(__dirname, 'src/'),
+ CSS_ROOT: path.resolve(__dirname, 'css/'),
+ SCSS_ROOT: path.resolve(__dirname, 'scss/')
+ }
+ },
module: {
rules: [
{
// 在任意入口文件中,通过预定义的名称
// 快速定位目标依赖文件的位置
import Vue from 'vue'
import App from './App.vue'
-import css from '../../scss/main.scss'
+import css from 'SCSS_ROOT/main.scss'
const app = new Vue({
render: h => h(App)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment